talloc_set_log_stderr();
- filename_tree = fr_rb_tree_talloc_alloc(NULL, rc_file_pair_t, node, filename_cmp, NULL, 0);
+ filename_tree = fr_rb_talloc_alloc(NULL, rc_file_pair_t, node, filename_cmp, NULL, 0);
if (!filename_tree) {
oom:
ERROR("Out of memory");
usage(64);
}
- link_tree = fr_rb_tree_talloc_alloc(conf, rs_request_t, link_node, rs_rtx_cmp, _unmark_link, 0);
+ link_tree = fr_rb_talloc_alloc(conf, rs_request_t, link_node, rs_rtx_cmp, _unmark_link, 0);
if (!link_tree) {
ERROR("Failed creating RTX tree");
goto finish;
/*
* Setup the request tree
*/
- request_tree = fr_rb_tree_talloc_alloc(conf, rs_request_t, request_node, rs_packet_cmp, _unmark_request, 0);
+ request_tree = fr_rb_talloc_alloc(conf, rs_request_t, request_node, rs_packet_cmp, _unmark_request, 0);
if (!request_tree) {
ERROR("Failed creating request tree");
goto finish;
* #todo - unify the code with static clients?
*/
if (inst->app_io->track_duplicates) {
- MEM(connection->client->table = fr_rb_tree_talloc_alloc(client, fr_io_track_t, node,
+ MEM(connection->client->table = fr_rb_talloc_alloc(client, fr_io_track_t, node,
track_connected_cmp, NULL, RB_FLAG_NONE));
}
*/
if (inst->app_io->track_duplicates) {
fr_assert(inst->app_io->compare != NULL);
- MEM(client->table = fr_rb_tree_talloc_alloc(client, fr_io_track_t, node, track_cmp,
+ MEM(client->table = fr_rb_talloc_alloc(client, fr_io_track_t, node, track_cmp,
NULL, RB_FLAG_NONE));
}
fr_assert(client->state == PR_CLIENT_STATIC);
(void) pthread_mutex_init(&client->mutex, NULL);
- MEM(client->ht = fr_hash_table_create(client, connection_hash, connection_cmp, NULL));
+ MEM(client->ht = fr_hash_table_alloc(client, connection_hash, connection_cmp, NULL));
}
/*
* defined.
*/
(void) pthread_mutex_init(&client->mutex, NULL);
- MEM(client->ht = fr_hash_table_create(client, connection_hash, connection_cmp, NULL));
+ MEM(client->ht = fr_hash_table_alloc(client, connection_hash, connection_cmp, NULL));
} else {
/*
/*
* Create the various heaps.
*/
- nr->sockets = fr_rb_tree_talloc_alloc(nr, fr_network_socket_t, listen_node, socket_listen_cmp, NULL, rbflags);
+ nr->sockets = fr_rb_talloc_alloc(nr, fr_network_socket_t, listen_node, socket_listen_cmp, NULL, rbflags);
if (!nr->sockets) {
fr_strerror_const_push("Failed creating listen tree for sockets");
goto fail2;
}
- nr->sockets_by_num = fr_rb_tree_talloc_alloc(nr, fr_network_socket_t, num_node, socket_num_cmp, NULL, rbflags);
+ nr->sockets_by_num = fr_rb_talloc_alloc(nr, fr_network_socket_t, num_node, socket_num_cmp, NULL, rbflags);
if (!nr->sockets_by_num) {
fr_strerror_const_push("Failed creating number tree for sockets");
goto fail2;
goto fail;
}
- worker->dedup = fr_rb_tree_talloc_alloc(worker, request_t, dedup_node, worker_dedup_cmp, NULL, rbflags);
+ worker->dedup = fr_rb_talloc_alloc(worker, request_t, dedup_node, worker_dedup_cmp, NULL, rbflags);
if (!worker->dedup) {
fr_strerror_const("Failed creating de_dup tree");
goto fail;
p = strrchr(cp->value, FR_DIR_SEP);
if (p) *p = '\0';
- MEM(tree = fr_rb_tree_talloc_alloc(cs, cf_file_t, node, _inode_cmp, NULL, 0));
+ MEM(tree = fr_rb_talloc_alloc(cs, cf_file_t, node, _inode_cmp, NULL, 0));
cf_data_add(cs, tree, "filename", false);
#else /* WITH_TRIE */
if (!clients->tree[client->ipaddr.prefix]) {
- clients->tree[client->ipaddr.prefix] = fr_rb_tree_talloc_alloc(clients, RADCLIENT, node, client_cmp,
+ clients->tree[client->ipaddr.prefix] = fr_rb_talloc_alloc(clients, RADCLIENT, node, client_cmp,
NULL, RB_FLAG_NONE);
if (!clients->tree[client->ipaddr.prefix]) {
return false;
}
dl_search_path_prepend(dl_module_loader->dl_loader, lib_dir);
- dl_module_loader->inst_data_tree = fr_rb_tree_talloc_alloc(dl_module_loader,
+ dl_module_loader->inst_data_tree = fr_rb_talloc_alloc(dl_module_loader,
dl_module_inst_t, node,
dl_module_inst_data_cmp, NULL, 0);
if (!dl_module_loader->inst_data_tree) {
goto error;
}
- dl_module_loader->module_tree = fr_rb_tree_talloc_alloc(dl_module_loader,
+ dl_module_loader->module_tree = fr_rb_talloc_alloc(dl_module_loader,
dl_module_t, node,
dl_module_cmp, NULL, 0);
if (!dl_module_loader->inst_data_tree) {
fr_assert(name && name[0]);
if (!map_proc_root) {
- map_proc_root = fr_rb_tree_talloc_alloc(NULL, map_proc_t, node,
+ map_proc_root = fr_rb_talloc_alloc(NULL, map_proc_t, node,
map_proc_cmp, _map_proc_tree_free, RB_FLAG_REPLACE);
if (!map_proc_root) {
DEBUG("map_proc: Failed to create tree");
module_method_set_t *set;
MEM(set = talloc_zero(ctx, module_method_set_t));
- MEM(set->tree = fr_rb_tree_talloc_alloc(set, module_method_entry_t, node, module_method_cmp, NULL, 0));
+ MEM(set->tree = fr_rb_talloc_alloc(set, module_method_entry_t, node, module_method_cmp, NULL, 0));
fr_dlist_talloc_init(&set->list, module_method_entry_t, entry);
return set;
* are freed before it's destroyed. Hence
* it being parented from the NULL ctx.
*/
- state->tree = fr_rb_tree_talloc_alloc(NULL, fr_state_entry_t, node, state_entry_cmp, NULL, 0);
+ state->tree = fr_rb_talloc_alloc(NULL, fr_state_entry_t, node, state_entry_cmp, NULL, 0);
if (!state->tree) {
talloc_free(state);
return NULL;
return 0;
}
- MEM(trigger_last_fired_tree = fr_rb_tree_talloc_alloc(talloc_null_ctx(),
+ MEM(trigger_last_fired_tree = fr_rb_talloc_alloc(talloc_null_ctx(),
trigger_last_fired_t, node,
_trigger_last_fired_cmp, _trigger_last_fired_free, 0));
* so it shouldn't be parented from
* virtual_server_root.
*/
- MEM(vns_tree = fr_rb_tree_talloc_alloc(NULL,
+ MEM(vns_tree = fr_rb_talloc_alloc(NULL,
fr_virtual_namespace_t, node,
_virtual_namespace_cmp,
_virtual_namespace_free, RB_FLAG_REPLACE));
/*
* Create the function tree
*/
- xlat_root = fr_rb_tree_talloc_alloc(NULL, xlat_t, node, xlat_cmp, _xlat_func_tree_free, RB_FLAG_REPLACE);
+ xlat_root = fr_rb_talloc_alloc(NULL, xlat_t, node, xlat_cmp, _xlat_func_tree_free, RB_FLAG_REPLACE);
if (!xlat_root) {
ERROR("%s: Failed to create tree", __FUNCTION__);
return -1;
if (!xlat_inst_tree) return 0;
if (!xlat_thread_inst_tree) {
- MEM(xlat_thread_inst_tree = fr_rb_tree_talloc_alloc(ctx, xlat_thread_inst_t, inst_node,
+ MEM(xlat_thread_inst_tree = fr_rb_talloc_alloc(ctx, xlat_thread_inst_t, inst_node,
_xlat_thread_inst_cmp, _xlat_thread_inst_free, 0));
}
{
if (xlat_inst_tree) return 0;
- xlat_inst_tree = fr_rb_tree_talloc_alloc(NULL, xlat_inst_t, inst_node,
+ xlat_inst_tree = fr_rb_talloc_alloc(NULL, xlat_inst_t, inst_node,
_xlat_inst_cmp, _xlat_inst_free, RB_FLAG_NONE);
if (!xlat_inst_tree) return -1;
* namespace hash table.
*/
if (!ext->namespace) {
- ext->namespace = fr_hash_table_create(*da_p, dict_attr_name_hash, dict_attr_name_cmp, NULL);
+ ext->namespace = fr_hash_table_alloc(*da_p, dict_attr_name_hash, dict_attr_name_cmp, NULL);
if (!ext->namespace) {
fr_strerror_printf("Failed allocating \"namespace\" table");
return -1;
* Initialise enumv hash tables
*/
if (!ext->value_by_name || !ext->name_by_value) {
- ext->value_by_name = fr_hash_table_create(da, dict_enum_name_hash, dict_enum_name_cmp, hash_pool_free);
+ ext->value_by_name = fr_hash_table_alloc(da, dict_enum_name_hash, dict_enum_name_cmp, hash_pool_free);
if (!ext->value_by_name) {
fr_strerror_printf("Failed allocating \"value_by_name\" table");
return -1;
}
- ext->name_by_value = fr_hash_table_create(da, dict_enum_value_hash, dict_enum_value_cmp, NULL);
+ ext->name_by_value = fr_hash_table_alloc(da, dict_enum_value_hash, dict_enum_value_cmp, NULL);
if (!ext->name_by_value) {
fr_strerror_printf("Failed allocating \"name_by_value\" table");
return -1;
* Create the table of vendor by name. There MAY NOT
* be multiple vendors of the same name.
*/
- dict->vendors_by_name = fr_hash_table_create(dict, dict_vendor_name_hash, dict_vendor_name_cmp, hash_pool_free);
+ dict->vendors_by_name = fr_hash_table_alloc(dict, dict_vendor_name_hash, dict_vendor_name_cmp, hash_pool_free);
if (!dict->vendors_by_name) {
fr_strerror_printf("Failed allocating \"vendors_by_name\" table");
goto error;
* be vendors of the same value. If there are, we
* pick the latest one.
*/
- dict->vendors_by_num = fr_hash_table_create(dict, dict_vendor_pen_hash, dict_vendor_pen_cmp, NULL);
+ dict->vendors_by_num = fr_hash_table_alloc(dict, dict_vendor_pen_hash, dict_vendor_pen_cmp, NULL);
if (!dict->vendors_by_num) {
fr_strerror_printf("Failed allocating \"vendors_by_num\" table");
goto error;
/*
* Inter-dictionary reference caching
*/
- dict->autoref = fr_hash_table_create(dict, dict_protocol_name_hash, dict_protocol_name_cmp, NULL);
+ dict->autoref = fr_hash_table_alloc(dict, dict_protocol_name_hash, dict_protocol_name_cmp, NULL);
if (!dict->autoref) {
fr_strerror_printf("Failed allocating \"autoref\" table");
goto error;
return NULL;
}
- new_ctx->protocol_by_name = fr_hash_table_create(new_ctx, dict_protocol_name_hash, dict_protocol_name_cmp, NULL);
+ new_ctx->protocol_by_name = fr_hash_table_alloc(new_ctx, dict_protocol_name_hash, dict_protocol_name_cmp, NULL);
if (!new_ctx->protocol_by_name) {
fr_strerror_const("Failed initializing protocol_by_name hash");
error:
return NULL;
}
- new_ctx->protocol_by_num = fr_hash_table_create(new_ctx, dict_protocol_num_hash, dict_protocol_num_cmp, NULL);
+ new_ctx->protocol_by_num = fr_hash_table_alloc(new_ctx, dict_protocol_num_hash, dict_protocol_num_cmp, NULL);
if (!new_ctx->protocol_by_num) {
fr_strerror_const("Failed initializing protocol_by_num hash");
goto error;
return NULL;
}
- dl_loader->tree = fr_rb_tree_talloc_alloc(dl_loader, dl_t, node, dl_handle_cmp, NULL, 0);
+ dl_loader->tree = fr_rb_talloc_alloc(dl_loader, dl_t, node, dl_handle_cmp, NULL, 0);
if (!dl_loader->tree) {
fr_strerror_const("Failed initialising dl->tree");
error:
return NULL;
}
- el->fds = fr_rb_tree_talloc_alloc(el, fr_event_fd_t, node, fr_event_fd_cmp, NULL, 0);
+ el->fds = fr_rb_talloc_alloc(el, fr_event_fd_t, node, fr_event_fd_cmp, NULL, 0);
if (!el->fds) {
fr_strerror_const("Failed allocating FD tree");
goto error;
*
* Memory usage in bytes is (20/3) * number of entries.
*/
-fr_hash_table_t *fr_hash_table_create(TALLOC_CTX *ctx,
+fr_hash_table_t *fr_hash_table_alloc(TALLOC_CTX *ctx,
fr_hash_t hash_func,
fr_cmp_t cmp_func,
fr_free_t free_func)
fr_hash_table_t *ht;
int *array;
- ht = fr_hash_table_create(NULL, hash_int, NULL, NULL);
+ ht = fr_hash_table_alloc(NULL, hash_int, NULL, NULL);
if (!ht) {
fprintf(stderr, "Hash create failed\n");
fr_exit(1);
typedef struct fr_hash_table_s fr_hash_table_t;
typedef int (*fr_hash_table_walk_t)(void *data, void *uctx);
-fr_hash_table_t *fr_hash_table_create(TALLOC_CTX *ctx,
+fr_hash_table_t *fr_hash_table_alloc(TALLOC_CTX *ctx,
fr_hash_t hashNode,
fr_cmp_t cmpNode,
fr_free_t freeNode);
* - A new rbtree on success.
* - NULL on failure.
*/
-#define fr_rb_tree_talloc_alloc(_ctx, _type, _field, _cmp, _node_free, _flags) \
+#define fr_rb_talloc_alloc(_ctx, _type, _field, _cmp, _node_free, _flags) \
_Generic((((_type *)0)->_field), \
fr_rb_node_t: _fr_rb_alloc(_ctx, offsetof(_type, _field), #_type, _cmp, _node_free, _flags) \
)
}
}
- sock->session_tree = fr_rb_tree_talloc_alloc(sock, bfd_state_t, node, bfd_session_cmp, bfd_session_free, 0);
+ sock->session_tree = fr_rb_talloc_alloc(sock, bfd_state_t, node, bfd_session_cmp, bfd_session_free, 0);
if (!sock->session_tree) {
ERROR("Failed creating session tree!");
return -1;
* these are specific to the connection.
*/
if (!conn->uctx) {
- MEM(tree = fr_rb_tree_talloc_alloc(conn, sync_state_t, node, _sync_cmp, NULL, RB_FLAG_NONE));
+ MEM(tree = fr_rb_talloc_alloc(conn, sync_state_t, node, _sync_cmp, NULL, RB_FLAG_NONE));
conn->uctx = tree;
} else {
tree = talloc_get_type_abort(conn->uctx, fr_rb_tree_t);
/*
* The cache.
*/
- driver->cache = fr_rb_tree_talloc_alloc(NULL, rlm_cache_rb_entry_t, node, cache_entry_cmp, NULL, 0);
+ driver->cache = fr_rb_talloc_alloc(NULL, rlm_cache_rb_entry_t, node, cache_entry_cmp, NULL, 0);
if (!driver->cache) {
ERROR("Failed to create cache");
return -1;
(inst->key_data_type == FR_TYPE_IPV6_ADDR) || (inst->key_data_type == FR_TYPE_IPV6_PREFIX)) {
MEM(inst->trie = fr_trie_alloc(inst));
} else {
- MEM(inst->tree = fr_rb_tree_talloc_alloc(inst, rlm_csv_entry_t, node, csv_entry_cmp, NULL, 0));
+ MEM(inst->tree = fr_rb_talloc_alloc(inst, rlm_csv_entry_t, node, csv_entry_cmp, NULL, 0));
}
if ((*inst->index_field_name == ',') || (*inst->index_field_name == *inst->delimiter)) {
if (cs) {
CONF_ITEM *ci;
- inst->ht = fr_hash_table_create(inst, detail_hash, detail_cmp, NULL);
+ inst->ht = fr_hash_table_alloc(inst, detail_hash, detail_cmp, NULL);
for (ci = cf_item_next(cs, NULL);
ci != NULL;
* thousands of "host" entries in the parent->child list.
*/
if (!parent->hosts_by_ether) {
- parent->hosts_by_ether = fr_hash_table_create(parent, host_ether_hash, host_ether_cmp, NULL);
+ parent->hosts_by_ether = fr_hash_table_alloc(parent, host_ether_hash, host_ether_cmp, NULL);
if (!parent->hosts_by_ether) {
return -1;
}
*/
if (my_uid) {
if (!parent->hosts_by_uid) {
- parent->hosts_by_uid = fr_hash_table_create(parent, host_uid_hash, host_uid_cmp, NULL);
+ parent->hosts_by_uid = fr_hash_table_alloc(parent, host_uid_hash, host_uid_cmp, NULL);
if (!parent->hosts_by_uid) {
return -1;
}
fr_pair_list_init(&info->options);
info->last = &(info->child);
- inst->hosts_by_ether = fr_hash_table_create(inst, host_ether_hash, host_ether_cmp, NULL);
+ inst->hosts_by_ether = fr_hash_table_alloc(inst, host_ether_hash, host_ether_cmp, NULL);
if (!inst->hosts_by_ether) return -1;
- inst->hosts_by_uid = fr_hash_table_create(inst, host_uid_hash, host_uid_cmp, NULL);
+ inst->hosts_by_uid = fr_hash_table_alloc(inst, host_uid_hash, host_uid_cmp, NULL);
if (!inst->hosts_by_uid) return -1;
ret = read_file(inst, info, inst->filename);
* If needed, allocate a subtree.
*/
if (!tt->subtree[tt->next_id]) {
- MEM(tt->subtree[tt->next_id] = fr_rb_tree_talloc_alloc(tt, radius_track_entry_t, node,
+ MEM(tt->subtree[tt->next_id] = fr_rb_talloc_alloc(tt, radius_track_entry_t, node,
te_cmp, NULL, RB_FLAG_NONE));
}
* Lookup sessions in the tree. We don't free them in
* the tree, as that's taken care of elsewhere...
*/
- inst->session_tree = fr_rb_tree_talloc_alloc(NULL, SECURID_SESSION, node, securid_session_cmp, NULL, 0);
+ inst->session_tree = fr_rb_talloc_alloc(NULL, SECURID_SESSION, node, securid_session_cmp, NULL, 0);
if (!inst->session_tree) {
ERROR("Cannot initialize session tree");
return -1;
return 0;
}
- txn_tree = fr_rb_tree_talloc_alloc(NULL, sigtran_transaction_t, node, sigtran_txn_cmp, false, 0);
+ txn_tree = fr_rb_talloc_alloc(NULL, sigtran_transaction_t, node, sigtran_txn_cmp, false, 0);
if (!txn_tree) return -1;
txn_tree_inst++;
t->inst = inst;
- t->src = fr_rb_tree_talloc_alloc(t, rlm_stats_data_t, src_node, data_cmp, NULL, RB_FLAG_LOCK);
- t->dst = fr_rb_tree_talloc_alloc(t, rlm_stats_data_t, dst_node, data_cmp, NULL, RB_FLAG_LOCK);
+ t->src = fr_rb_talloc_alloc(t, rlm_stats_data_t, src_node, data_cmp, NULL, RB_FLAG_LOCK);
+ t->dst = fr_rb_talloc_alloc(t, rlm_stats_data_t, dst_node, data_cmp, NULL, RB_FLAG_LOCK);
pthread_mutex_lock(&inst->mutex);
fr_dlist_insert_head(&inst->list, t);