Commit 1ce15daa authored by Lucas Russo's avatar Lucas Russo

src,include/*: change zlist,zhash to more performatic zlistx,zhashx

parent b1a18ddc
......@@ -45,14 +45,14 @@ typedef struct {
spawn_broker_handler_fp dmngr_spawn_broker; /* Called to spawn (or respawn a zeroMQ broker */
/* List of dmngr_sig_handler_t */
zlist_t *sig_ops;
zlistx_t *sig_ops;
} dmngr_ops_t;
/***************** Our methods *****************/
/* Creates a new instance of the Device Manager */
dmngr_t * dmngr_new (char *name, char *endpoint, int verbose,
const char *log_prefix, zhash_t *hints_h);
const char *log_prefix, zhashx_t *hints_h);
/* Destroy an instance of the Device Manager */
dmngr_err_e dmngr_destroy (dmngr_t **self_p);
......
......@@ -61,11 +61,11 @@
static devio_err_e _spawn_assoc_devios (devio_t *devio, uint32_t dev_id,
devio_type_e devio_type, char *cfg_file, char *broker_endp,
char *log_prefix, zhash_t *hints);
char *log_prefix, zhashx_t *hints);
static devio_err_e _spawn_rffe_devios (devio_t *devio, uint32_t dev_id,
char *cfg_file, char *broker_endp, char *log_prefix, zhash_t *hints);
char *cfg_file, char *broker_endp, char *log_prefix, zhashx_t *hints);
static devio_err_e _spawn_epics_iocs (devio_t *devio, uint32_t dev_id,
char *cfg_file, char *broker_endp, char *log_prefix, zhash_t *hints);
char *cfg_file, char *broker_endp, char *log_prefix, zhashx_t *hints);
static char *_create_log_filename (char *log_prefix, uint32_t dev_id,
const char *devio_type, uint32_t smio_inst_id);
static devio_err_e _spawn_platform_smios (devio_t *devio, devio_type_e devio_type,
......@@ -347,7 +347,7 @@ int main (int argc, char *argv[])
/* Print SDB devices */
devio_print_info (devio);
zhash_t *devio_hints = zhash_new ();
zhashx_t *devio_hints = zhashx_new ();
if (devio_hints == NULL) {
DBE_DEBUG (DBG_DEV_MNGR | DBG_LVL_FATAL, "[dev_io] Could allocate "
"hints hash table\n");
......@@ -420,7 +420,7 @@ err_assoc_devio:
err_cfg_get_hints:
zconfig_destroy (&root_cfg);
err_cfg_load:
zhash_destroy (&devio_hints);
zhashx_destroy (&devio_hints);
err_devio_hints_alloc:
free (devio_log_filename);
err_devio_log_filename_alloc:
......@@ -456,7 +456,7 @@ err_exit:
static devio_err_e _spawn_assoc_devios (devio_t *devio, uint32_t dev_id,
devio_type_e devio_type, char *cfg_file, char *broker_endp,
char *log_prefix, zhash_t *hints)
char *log_prefix, zhashx_t *hints)
{
assert (devio);
assert (broker_endp);
......@@ -493,7 +493,7 @@ err_spwan_assoc_devios:
}
static devio_err_e _spawn_rffe_devios (devio_t *devio, uint32_t dev_id,
char *cfg_file, char *broker_endp, char *log_prefix, zhash_t *hints)
char *cfg_file, char *broker_endp, char *log_prefix, zhashx_t *hints)
{
assert (devio);
assert (broker_endp);
......@@ -519,7 +519,7 @@ static devio_err_e _spawn_rffe_devios (devio_t *devio, uint32_t dev_id,
"Could not generate configuration hash key for configuration "
"file", err_cfg_exit, DEVIO_ERR_CFG);
hutils_hints_t *cfg_item = zhash_lookup (hints, hints_key);
hutils_hints_t *cfg_item = zhashx_lookup (hints, hints_key);
/* If key is not found, assume we don't have any more AFE to
* prepare */
if (cfg_item == NULL || cfg_item->bind == NULL ||
......@@ -566,7 +566,7 @@ err_cfg_exit:
}
static devio_err_e _spawn_epics_iocs (devio_t *devio, uint32_t dev_id,
char *cfg_file, char *broker_endp, char *log_prefix, zhash_t *hints)
char *cfg_file, char *broker_endp, char *log_prefix, zhashx_t *hints)
{
assert (devio);
assert (broker_endp);
......@@ -594,7 +594,7 @@ static devio_err_e _spawn_epics_iocs (devio_t *devio, uint32_t dev_id,
"Could not generate configuration hash key for configuration "
"file", err_cfg_exit, DEVIO_ERR_CFG);
hutils_hints_t *cfg_item = zhash_lookup (hints, hints_key);
hutils_hints_t *cfg_item = zhashx_lookup (hints, hints_key);
/* If key is not found or we were asked not to spawn EPICS IOC,
* assume we don't have any more DBE to prepare */
if (cfg_item == NULL || cfg_item->spawn_epics_ioc == false) {
......
......@@ -63,11 +63,11 @@ struct _devio_t {
/* Hash containing all the sm_io objects that
* this dev_io can handle. It is composed
* of key (10-char ID) / value (sm_io instance) */
zhash_t *sm_io_h;
zhashx_t *sm_io_h;
/* Hash containing all the Config sm_io objects that
* this dev_io can handle. It is composed
* of key (10-char ID) / value (sm_io instance) */
zhash_t *sm_io_cfg_h;
zhashx_t *sm_io_cfg_h;
/* Dispatch table containing all the sm_io thsafe operations
* that we need to handle. It is composed
* of key (4-char ID) / value (pointer to function) */
......@@ -85,8 +85,8 @@ static disp_table_err_e _devio_check_msg_args (disp_table_t *disp_table,
/* Do the SMIO operation */
static devio_err_e _devio_do_smio_op (devio_t *self, void *msg);
static devio_err_e _devio_send_destruct_msg (devio_t *self, zactor_t **actor);
static devio_err_e _devio_destroy_smio (devio_t *self, zhash_t *smio_h, const char *smio_key);
static devio_err_e _devio_destroy_smio_all (devio_t *self, zhash_t *smio_h);
static devio_err_e _devio_destroy_smio (devio_t *self, zhashx_t *smio_h, const char *smio_key);
static devio_err_e _devio_destroy_smio_all (devio_t *self, zhashx_t *smio_h);
/* Creates a new instance of Device Information */
devio_t * devio_new (char *name, uint32_t id, char *endpoint_dev,
......@@ -176,11 +176,11 @@ devio_t * devio_new (char *name, uint32_t id, char *endpoint_dev,
self->thsafe_server_ops = smio_thsafe_zmq_server_ops;
/* Init sm_io_h hash */
self->sm_io_h = zhash_new ();
self->sm_io_h = zhashx_new ();
ASSERT_ALLOC(self->sm_io_h, err_sm_io_h_alloc);
/* Init sm_io_cfg_h hash */
self->sm_io_cfg_h = zhash_new ();
self->sm_io_cfg_h = zhashx_new ();
ASSERT_ALLOC(self->sm_io_cfg_h, err_sm_io_cfg_h_alloc);
/* Init sm_io_thsafe_ops_h dispatch table */
......@@ -203,9 +203,9 @@ devio_t * devio_new (char *name, uint32_t id, char *endpoint_dev,
err_disp_table_init:
disp_table_destroy (&self->disp_table_thsafe_ops);
err_disp_table_thsafe_ops_alloc:
zhash_destroy (&self->sm_io_cfg_h);
zhashx_destroy (&self->sm_io_cfg_h);
err_sm_io_cfg_h_alloc:
zhash_destroy (&self->sm_io_h);
zhashx_destroy (&self->sm_io_h);
err_sm_io_h_alloc:
llio_release (self->llio, NULL);
err_llio_open:
......@@ -251,8 +251,8 @@ devio_err_e devio_destroy (devio_t **self_p)
* unregister from broker as soon as possible to avoid
* loosing requests from clients */
disp_table_destroy (&self->disp_table_thsafe_ops);
zhash_destroy (&self->sm_io_cfg_h);
zhash_destroy (&self->sm_io_h);
zhashx_destroy (&self->sm_io_cfg_h);
zhashx_destroy (&self->sm_io_h);
self->thsafe_server_ops = NULL;
llio_release (self->llio, NULL);
llio_destroy (&self->llio);
......@@ -423,7 +423,7 @@ devio_err_e devio_register_sm (devio_t *self, uint32_t smio_id, uint64_t base,
DBE_DEBUG (DBG_DEV_IO | DBG_LVL_TRACE,
"[dev_io_core:register_sm] Inserting hash with key: %s\n", key);
int zerr = zhash_insert (self->sm_io_h, key, &self->pipes_mgmt [pipe_mgmt_idx]);
int zerr = zhashx_insert (self->sm_io_h, key, &self->pipes_mgmt [pipe_mgmt_idx]);
/* We must not fail here, as we will loose our reference to the SMIO
* thread otherwise */
ASSERT_TEST (zerr == 0, "Could not insert PIPE hash key. Duplicated value?",
......@@ -460,7 +460,7 @@ devio_err_e devio_register_sm (devio_t *self, uint32_t smio_id, uint64_t base,
DBE_DEBUG (DBG_DEV_IO | DBG_LVL_TRACE,
"[dev_io_core:register_sm] Inserting config hash with key: %s\n", key);
zerr = zhash_insert (self->sm_io_cfg_h, key, &self->pipes_config [pipe_config_idx]);
zerr = zhashx_insert (self->sm_io_cfg_h, key, &self->pipes_config [pipe_config_idx]);
/* We must not fail here, as we will loose our reference to the SMIO
* thread otherwise */
ASSERT_TEST (zerr == 0, "Could not insert Config PIPE hash key. Duplicated value?",
......@@ -484,7 +484,7 @@ devio_err_e devio_register_sm (devio_t *self, uint32_t smio_id, uint64_t base,
return DEVIO_SUCCESS;
err_poller_config_insert:
zhash_delete (self->sm_io_cfg_h, key);
zhashx_delete (self->sm_io_cfg_h, key);
err_cfg_pipe_hash_insert:
/* If we can't insert the SMIO thread key in hash,
* destroy it as we won't have a reference to it later! */
......@@ -495,7 +495,7 @@ err_spawn_config_thread:
err_th_config_args_alloc:
zpoller_remove (self->poller, self->pipes_msg [pipe_msg_idx]);
err_poller_insert:
zhash_delete (self->sm_io_h, key);
zhashx_delete (self->sm_io_h, key);
err_pipe_hash_insert:
/* If we can't insert the SMIO thread key in hash,
* destroy it as we won't have a reference to it later! */
......@@ -720,25 +720,25 @@ err_hand_req:
return err;
}
static devio_err_e _devio_destroy_smio_all (devio_t *self, zhash_t *smio_h)
static devio_err_e _devio_destroy_smio_all (devio_t *self, zhashx_t *smio_h)
{
assert (self);
devio_err_e err = DEVIO_SUCCESS;
/* Get all hash keys */
zlist_t *hash_keys = zhash_keys (smio_h);
zlistx_t *hash_keys = zhashx_keys (smio_h);
ASSERT_ALLOC (hash_keys, err_hash_keys_alloc, DEVIO_ERR_ALLOC);
char *hash_item = zlist_first (hash_keys);
char *hash_item = zlistx_first (hash_keys);
/* Iterate over all keys removing each of one */
for (; hash_item != NULL; hash_item = zlist_next (hash_keys)) {
for (; hash_item != NULL; hash_item = zlistx_next (hash_keys)) {
err = _devio_destroy_smio (self, smio_h, hash_item);
ASSERT_TEST (err == DEVIO_SUCCESS, "Could not destroy SMIO "
"instance", err_smio_destroy, DEVIO_ERR_SMIO_DESTROY);
}
err_smio_destroy:
zlist_destroy (&hash_keys);
zlistx_destroy (&hash_keys);
err_hash_keys_alloc:
return err;
}
......@@ -776,13 +776,13 @@ err_msg_alloc:
/* smio_key is the name of the SMIO + instance number, e.g.,
* FMC130M_4CH0*/
static devio_err_e _devio_destroy_smio (devio_t *self, zhash_t *smio_h, const char *smio_key)
static devio_err_e _devio_destroy_smio (devio_t *self, zhashx_t *smio_h, const char *smio_key)
{
assert (self);
devio_err_e err = DEVIO_SUCCESS;
/* Lookup SMIO reference in hash table */
zactor_t **actor = (zactor_t **) zhash_lookup (smio_h, smio_key);
zactor_t **actor = (zactor_t **) zhashx_lookup (smio_h, smio_key);
ASSERT_TEST (actor != NULL, "Could not find SMIO registered with this ID",
err_hash_lookup, DEVIO_ERR_SMIO_DESTROY);
......@@ -792,7 +792,7 @@ static devio_err_e _devio_destroy_smio (devio_t *self, zhash_t *smio_h, const ch
/* Finally, remove the pipe from hash. FIXME: What if the SMIO does not
* exit? We will loose its reference ...*/
zhash_delete (smio_h, smio_key);
zhashx_delete (smio_h, smio_key);
err_send_msg:
err_hash_lookup:
......
......@@ -77,7 +77,7 @@ int main (int argc, char *argv[])
}
}
zhash_t *dmngr_hints = zhash_new ();
zhashx_t *dmngr_hints = zhashx_new ();
if (dmngr_hints == NULL) {
DBE_DEBUG (DBG_DEV_MNGR | DBG_LVL_FATAL, "[dev_mngr] Could allocate "
"hints hash table\n");
......@@ -352,7 +352,7 @@ err_dmngr_alloc:
err_daemonize:
zconfig_destroy (&root_cfg);
err_cfg_exit:
zhash_destroy (&dmngr_hints);
zhashx_destroy (&dmngr_hints);
err_dmngr_hints_alloc:
str_p = &cfg_file;
free (*str_p);
......
......@@ -81,8 +81,8 @@ struct _dmngr_t {
bool broker_running; /* true if broker is already running */
/* Device managment */
zhash_t *devio_info_h;
zhash_t *hints_h; /* Config hints from configuration file */
zhashx_t *devio_info_h;
zhashx_t *hints_h; /* Config hints from configuration file */
};
/* Configuration variables. To be filled by dev_mngr */
......@@ -97,7 +97,7 @@ char *dmngr_work_dir = NULL;
char *dmngr_spawn_broker_cfg_str = NULL;
int dmngr_spawn_broker_cfg = 0;
static void _devio_hash_free_item (void *data);
static void _devio_hash_free_item (void **data);
static dmngr_err_e _dmngr_scan_devs (dmngr_t *self, uint32_t *num_devs_found);
static dmngr_err_e _dmngr_prepare_devio (dmngr_t *self, const char *key,
char *dev_pathname, uint32_t id, llio_type_e type,
......@@ -105,7 +105,7 @@ static dmngr_err_e _dmngr_prepare_devio (dmngr_t *self, const char *key,
/* Creates a new instance of the Device Manager */
dmngr_t * dmngr_new (char *name, char *endpoint, int verbose,
const char *log_prefix, zhash_t *hints_h)
const char *log_prefix, zhashx_t *hints_h)
{
assert (name);
assert (endpoint);
......@@ -138,14 +138,18 @@ dmngr_t * dmngr_new (char *name, char *endpoint, int verbose,
self->ops = (dmngr_ops_t *) zmalloc (sizeof *self->ops);
ASSERT_ALLOC(self->ops, err_ops_alloc);
self->ops->sig_ops = zlist_new ();
self->ops->sig_ops = zlistx_new ();
ASSERT_ALLOC(self->ops->sig_ops, err_list_alloc);
/* Init devio_info hash */
self->devio_info_h = zhash_new ();
self->devio_info_h = zhashx_new ();
ASSERT_ALLOC(self->devio_info_h, err_devio_info_h_alloc);
zhashx_set_destructor (self->devio_info_h, _devio_hash_free_item);
self->hints_h = zhash_dup (hints_h);
/* FIXME: set duplicator in hints_h before calling dup method. Without a
* duplicator method set, zhashx_dup () does not duplicate the item and
* just points to the same reference */
self->hints_h = zhashx_dup (hints_h);
ASSERT_ALLOC(self->hints_h, err_hints_h_alloc);
self->broker_running = false;
......@@ -175,9 +179,9 @@ err_dealer_bind:
zsock_destroy (&self->dealer);
err_dealer_alloc:
err_hints_h_alloc:
zhash_destroy (&self->devio_info_h);
zhashx_destroy (&self->devio_info_h);
err_devio_info_h_alloc:
zlist_destroy (&self->ops->sig_ops);
zlistx_destroy (&self->ops->sig_ops);
err_list_alloc:
free (self->ops);
err_ops_alloc:
......@@ -201,9 +205,9 @@ dmngr_err_e dmngr_destroy (dmngr_t **self_p)
/* Starting destructing by the last resource */
zsock_unbind (self->dealer, "%s", self->endpoint);
zsock_destroy (&self->dealer);
zhash_destroy (&self->hints_h);
zhash_destroy (&self->devio_info_h);
zlist_destroy (&self->ops->sig_ops);
zhashx_destroy (&self->hints_h);
zhashx_destroy (&self->devio_info_h);
zlistx_destroy (&self->ops->sig_ops);
free (self->ops);
free (self->endpoint);
free (self->name);
......@@ -218,16 +222,16 @@ dmngr_err_e dmngr_destroy (dmngr_t **self_p)
dmngr_err_e dmngr_set_sig_handler (dmngr_t *self, dmngr_sig_handler_t *sig_handler)
{
assert (self);
int err = zlist_append (self->ops->sig_ops, sig_handler);
void *handle = zlistx_add_end (self->ops->sig_ops, sig_handler);
return (err == -1) ? DMNGR_ERR_ALLOC : DMNGR_SUCCESS;
return (handle == NULL) ? DMNGR_ERR_ALLOC : DMNGR_SUCCESS;
}
dmngr_err_e dmngr_register_sig_handlers (dmngr_t *self)
{
assert (self);
dmngr_sig_handler_t *sig_handler =
(dmngr_sig_handler_t *) zlist_first (self->ops->sig_ops);
(dmngr_sig_handler_t *) zlistx_first (self->ops->sig_ops);
/* Register all signal handlers in list*/
while (sig_handler) {
......@@ -244,7 +248,7 @@ dmngr_err_e dmngr_register_sig_handlers (dmngr_t *self)
sig_handler->signal);
sig_handler = (dmngr_sig_handler_t *)
zlist_next (self->ops->sig_ops);
zlistx_next (self->ops->sig_ops);
}
return DMNGR_SUCCESS;
......@@ -408,19 +412,19 @@ dmngr_err_e dmngr_spawn_all_devios (dmngr_t *self, char *broker_endp,
/* DBE_DEBUG (DBG_DEV_MNGR | DBG_LVL_TRACE, "[dev_mngr_core] Spawing all DEVIO workers\n");*/
/* Get all hash keys*/
zlist_t *devio_info_key_list = zhash_keys (self->devio_info_h);
zlistx_t *devio_info_key_list = zhashx_keys (self->devio_info_h);
ASSERT_ALLOC (devio_info_key_list, err_hash_keys_alloc, DMNGR_ERR_ALLOC);
char *devio_info_key = zlist_first (devio_info_key_list);
char *devio_info_key = zlistx_first (devio_info_key_list);
/* Iterate over all keys spawning the DEVIOs */
for (; devio_info_key != NULL; devio_info_key = zlist_next (devio_info_key_list)) {
for (; devio_info_key != NULL; devio_info_key = zlistx_next (devio_info_key_list)) {
/* Free any possibly dev_pathname allocated but not free'd */
free (dev_pathname);
dev_pathname = NULL;
/* Look for DEVIO */
devio_info_t *devio_info = zhash_lookup (self->devio_info_h,
devio_info_t *devio_info = zhashx_lookup (self->devio_info_h,
devio_info_key);
/* Get all devio_info properties */
......@@ -503,16 +507,16 @@ err_dev_type_c_alloc:
err_devio_type_c_alloc:
free (dev_pathname);
err_dev_pathname_alloc:
zlist_destroy (&devio_info_key_list);
zlistx_destroy (&devio_info_key_list);
err_hash_keys_alloc:
return err;
}
/************************ Local helper functions ******************/
/* Hash free function */
static void _devio_hash_free_item (void *data)
static void _devio_hash_free_item (void **data)
{
devio_info_destroy ((devio_info_t **) &data);
devio_info_destroy ((devio_info_t **) data);
}
static dmngr_err_e _dmngr_scan_devs (dmngr_t *self, uint32_t *num_devs_found)
......@@ -550,7 +554,7 @@ static dmngr_err_e _dmngr_scan_devs (dmngr_t *self, uint32_t *num_devs_found)
"Could not generate DBE config path", err_cfg_key,
DMNGR_ERR_CFG);
const devio_info_t *devio_info_lookup = zhash_lookup (self->devio_info_h,
const devio_info_t *devio_info_lookup = zhashx_lookup (self->devio_info_h,
key);
/* If device is already registered, do nothing */
......@@ -599,10 +603,7 @@ static dmngr_err_e _dmngr_prepare_devio (dmngr_t *self, const char *key,
DBE_DEBUG (DBG_DEV_MNGR | DBG_LVL_INFO,
"[dev_mngr_core:prepare_devio] Inserting device with key: %s\n", key);
zhash_insert (self->devio_info_h, key, devio_info);
/* Setup free function */
zhash_freefn (self->devio_info_h, key, _devio_hash_free_item);
zhashx_insert (self->devio_info_h, key, devio_info);
err_devio_info_alloc:
return err;
......
......@@ -44,7 +44,7 @@ struct _disp_table_t {
/* Hash containg all the sm_io thsafe operations
* that we need to handle. It is composed
* of key (4-char ID) / value (pointer to funtion) */
zhash_t *table_h;
zhashx_t *table_h;
/* Dispatch table operations */
const disp_table_ops_t *ops;
};
......@@ -53,7 +53,7 @@ static disp_table_err_e _disp_table_insert (disp_table_t *self, const disp_op_t*
static disp_table_err_e _disp_table_insert_all (disp_table_t *self, const disp_op_t **disp_ops);
static disp_table_err_e _disp_table_remove (disp_table_t *self, uint32_t key);
static disp_table_err_e _disp_table_remove_all (disp_table_t *self);
static void _disp_table_free_item (void *data);
static void _disp_table_free_item (void **data);
static disp_table_err_e _disp_table_check_args (disp_table_t *self, uint32_t key,
void *args, void **ret);
static int _disp_table_call (disp_table_t *self, uint32_t key, void *owner, void *args,
......@@ -72,10 +72,9 @@ disp_table_t *disp_table_new (const disp_table_ops_t *ops)
disp_table_t *self = zmalloc (sizeof *self);
ASSERT_ALLOC (self, err_self_alloc);
self->table_h = zhash_new ();
self->table_h = zhashx_new ();
ASSERT_ALLOC (self->table_h, err_table_h_alloc);
/* Only work for strings
zhash_autofree (self->table_h);*/
zhashx_set_destructor (self->table_h, _disp_table_free_item);
self->ops = ops;
return self;
......@@ -95,7 +94,7 @@ disp_table_err_e disp_table_destroy (disp_table_t **self_p)
_disp_table_remove_all (self);
self->ops = NULL;
zhash_destroy (&self->table_h);
zhashx_destroy (&self->table_h);
free (self);
*self_p = NULL;
}
......@@ -232,11 +231,9 @@ static disp_table_err_e _disp_table_insert (disp_table_t *self, const disp_op_t
char *key_c = hutils_stringify_hex_key (disp_op_handler->op->opcode);
ASSERT_ALLOC (key_c, err_key_c_alloc);
int zerr = zhash_insert (self->table_h, key_c, disp_op_handler);
int zerr = zhashx_insert (self->table_h, key_c, disp_op_handler);
ASSERT_TEST(zerr == 0, "Could not insert item into dispatch table",
err_insert_hash);
/* Setup free function */
zhash_freefn (self->table_h, key_c, _disp_table_free_item);
free (key_c);
return DISP_TABLE_SUCCESS;
......@@ -251,10 +248,10 @@ err_disp_op_handler_new:
return DISP_TABLE_ERR_ALLOC;
}
static void _disp_table_free_item (void *data)
static void _disp_table_free_item (void **data)
{
disp_op_handler_t *disp_op_handler = (disp_op_handler_t *) data;
disp_op_handler_destroy (&disp_op_handler);
disp_op_handler_t **disp_op_handler = (disp_op_handler_t **) data;
disp_op_handler_destroy (disp_op_handler);
}
static disp_table_err_e _disp_table_insert_all (disp_table_t *self, const disp_op_t **disp_ops)
......@@ -298,7 +295,7 @@ static disp_table_err_e _disp_table_remove (disp_table_t *self, uint32_t key)
"[disp_table] Removing function (key = %u) into dispatch table\n",
key);
/* This will trigger the free function previously registered */
zhash_delete (self->table_h, key_c);
zhashx_delete (self->table_h, key_c);
free (key_c);
return DISP_TABLE_SUCCESS;
......@@ -313,14 +310,14 @@ static disp_table_err_e _disp_table_remove_all (disp_table_t *self)
{
assert (self);
zlist_t *hash_keys = zhash_keys (self->table_h);
void * table_item = zlist_first (hash_keys);
zlistx_t *hash_keys = zhashx_keys (self->table_h);
void * table_item = zlistx_first (hash_keys);
for ( ; table_item; table_item = zlist_next (hash_keys)) {
for ( ; table_item; table_item = zlistx_next (hash_keys)) {
_disp_table_remove (self, hutils_numerify_hex_key ((char *) table_item));
}
zlist_destroy (&hash_keys);
zlistx_destroy (&hash_keys);
return DISP_TABLE_SUCCESS;
}
......@@ -454,7 +451,7 @@ static disp_op_handler_t *_disp_table_lookup (disp_table_t *self, uint32_t key)
char *key_c = hutils_stringify_hex_key (key);
ASSERT_ALLOC (key_c, err_key_c_alloc);
disp_op_handler = zhash_lookup (self->table_h, key_c);
disp_op_handler = zhashx_lookup (self->table_h, key_c);
ASSERT_TEST (disp_op_handler != NULL, "Could not find registered function",
err_func_p_wrapper_null);
......
......@@ -39,7 +39,7 @@
static char *_hutils_concat_strings_raw (const char *str1, const char* str2,
const char *str3, bool with_sep, char sep);
static void _hutils_hints_free_item (void *data);
static void _hutils_hints_free_item (void **data);
/*******************************************************************/
/***************** String manipulation functions ******************/
......@@ -310,16 +310,21 @@ err_copy_str:
/*******************************************************************/
/* Hash free function */
static void _hutils_hints_free_item (void *data)
static void _hutils_hints_free_item (void **data)
{
hutils_hints_t *item = data;
free (item->bind);
free (item);
assert (data);
if (*data) {
hutils_hints_t *item = *data;
free (item->bind);
free (item);
*data = NULL;
}
}
/* Get properties from config file (defined in http://rfc.zeromq.org/spec:4)
* and store them in hash table in the form <property name / property value> */
hutils_err_e hutils_get_hints (zconfig_t *root_cfg, zhash_t *hints_h)
hutils_err_e hutils_get_hints (zconfig_t *root_cfg, zhashx_t *hints_h)
{
assert (root_cfg);
assert (hints_h);
......@@ -327,6 +332,9 @@ hutils_err_e hutils_get_hints (zconfig_t *root_cfg, zhash_t *hints_h)
hutils_err_e err = HUTILS_SUCCESS;
hutils_hints_t *item = NULL;
/* Set destruction function */
zhashx_set_destructor (hints_h, _hutils_hints_free_item);
/* Read DEVIO suggested bind endpoints and fill the hash table with
* the corresponding keys */
......@@ -377,7 +385,7 @@ hutils_err_e hutils_get_hints (zconfig_t *root_cfg, zhash_t *hints_h)
char *spawn_epics_ioc = zconfig_resolve (bpm_cfg, "/spawn_epics_ioc",
NULL);
ASSERT_TEST (spawn_epics_ioc != NULL, "[hutils:utils] Could not find "
"EPICS IOC (spwan_epics_ioc = <value>) in configuration file",
"EPICS IOC (spwan_epics_ioc = <value>) in configuration file",
err_spawn_epics_ioc, HUTILS_ERR_CFG);
/* Convert yes/no to bool */
......@@ -412,12 +420,9 @@ hutils_err_e hutils_get_hints (zconfig_t *root_cfg, zhash_t *hints_h)
hints_key, afe_bind, spawn_epics_ioc);
/* Insert this value in the hash table */
errs = zhash_insert (hints_h, hints_key, item);
errs = zhashx_insert (hints_h, hints_key, item);
ASSERT_TEST (errs == 0, "Could not find insert AFE endpoint to "
"hash table", err_cfg_exit, HUTILS_ERR_CFG);
/* Setup free function */
zhash_freefn (hints_h, hints_key, _hutils_hints_free_item);
}
}
......
......@@ -103,6 +103,6 @@ int hutils_copy_str (char *dest, const char *src, size_t size);
/* Get properties from config file (defined in http://rfc.zeromq.org/spec:4)
* and store them in hash table in the form <property name / property value> */
hutils_err_e hutils_get_hints (zconfig_t *root_cfg, zhash_t *hints_h);
hutils_err_e hutils_get_hints (zconfig_t *root_cfg, zhashx_t *hints_h);
#endif
......@@ -93,7 +93,7 @@ llio_t * llio_new (char *name, char *endpoint, llio_type_e type, int verbose)
return self;
/*err_ops_alloc:
zlist_destroy(&self->dev_info->sdb); */
zlistx_destroy(&self->dev_info->sdb); */
/* err_dev_info_alloc:
llio_endpoint_destroy (&self->endpoint); */
err_endpoint_alloc:
......
......@@ -34,7 +34,7 @@
struct _llio_dev_info_t {
uint64_t sdb_addr; /* Location of the SDB structures in device */
bool parsed; /* True if device was already parsed */
zlist_t *sdb; /* List holding the SDB structures of the device */
zlistx_t *sdb; /* List holding the SDB structures of the device */
};
/* Creates a new instance of Device Information */
......@@ -48,7 +48,7 @@ llio_dev_info_t * llio_dev_info_new ()
later by read_dev_info() */
self->sdb_addr = 0x0;
self->parsed = false;
self->sdb = zlist_new (); /* HASH!? */
self->sdb = zlistx_new (); /* HASH!? */
ASSERT_ALLOC(self->sdb, err_sdb_alloc);
return self;
......@@ -68,7 +68,7 @@ llio_err_e llio_dev_info_destroy (llio_dev_info_t **self_p)
llio_dev_info_t *self = *self_p;
/* Starting destructing by the last resource */
zlist_destroy (&self->sdb);
zlistx_destroy (&self->sdb);
free (self);
*self_p = NULL;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment