Most of these uses should be fixed up to use a key callback anyway....
fr_trie_t *trie;
size_t i, num;
- MEM(trie = fr_trie_alloc(ctx));
+ MEM(trie = fr_trie_alloc(ctx, NULL, NULL));
num = talloc_array_length(allow);
fr_assert(num > 0);
/*
* Create the trie of clients for this socket.
*/
- MEM(thread->trie = fr_trie_alloc(thread));
+ MEM(thread->trie = fr_trie_alloc(thread, NULL, NULL));
MEM(thread->alive_clients = fr_heap_alloc(thread, alive_client_cmp,
fr_io_client_t, alive_id));
clients->name = talloc_strdup(clients, cs ? cf_section_name1(cs) : "root");
#ifdef WITH_TRIE
- clients->v4_udp = fr_trie_alloc(clients);
+ clients->v4_udp = fr_trie_alloc(clients, NULL, NULL);
if (!clients->v4_udp) {
talloc_free(clients);
return NULL;
}
- clients->v6_udp = fr_trie_alloc(clients);
+ clients->v6_udp = fr_trie_alloc(clients, NULL, NULL);
if (!clients->v6_udp) {
talloc_free(clients);
return NULL;
}
- clients->v4_tcp = fr_trie_alloc(clients);
+ clients->v4_tcp = fr_trie_alloc(clients, NULL, NULL);
if (!clients->v4_tcp) {
talloc_free(clients);
return NULL;
}
- clients->v6_tcp = fr_trie_alloc(clients);
+ clients->v6_tcp = fr_trie_alloc(clients, NULL, NULL);
if (!clients->v6_tcp) {
talloc_free(clients);
return NULL;
#include <freeradius-devel/util/htrie.h>
-fr_htrie_t *fr_htrie_create(TALLOC_CTX *ctx,
- fr_htrie_type_t type,
- fr_hash_t hash_node,
- fr_cmp_t cmp_node,
- fr_trie_key_t get_key,
- fr_free_t free_node)
+fr_htrie_t *fr_htrie_alloc(TALLOC_CTX *ctx,
+ fr_htrie_type_t type,
+ fr_hash_t hash_node,
+ fr_cmp_t cmp_node,
+ fr_trie_key_t get_key,
+ fr_free_t free_node)
{
fr_htrie_t *trie;
case FR_HTRIE_TRIE:
if (!get_key) return NULL;
- trie->ctx = fr_trie_generic_alloc(trie, get_key, free_node);
+ trie->ctx = fr_trie_alloc(trie, get_key, free_node);
if (!trie->ctx) {
talloc_free(trie);
return NULL;
*
* @file src/lib/util/htrie.h
*
- * @copyright 2005,2006 The FreeRADIUS server project
+ * @copyright 2021 The FreeRADIUS server project
*/
RCSIDH(htrie_h, "$Id$")
#include <freeradius-devel/util/hash.h>
#include <freeradius-devel/util/rb.h>
#include <freeradius-devel/util/trie.h>
-
+
typedef struct fr_htrie_s fr_htrie_t;
typedef void *(*fr_htrie_find_t)(fr_htrie_t *ht, void const *data);
fr_htrie_remove_t remove;
fr_htrie_delete_t delete;
fr_htrie_num_elements_t num_elements;
-
+
};
typedef enum {
FR_HTRIE_TRIE,
} fr_htrie_type_t;
-fr_htrie_t *fr_htrie_create(TALLOC_CTX *ctx,
+fr_htrie_t *fr_htrie_alloc(TALLOC_CTX *ctx,
fr_htrie_type_t type,
fr_hash_t hash_node,
fr_cmp_t cmp_node,
* - NULL on error
* - fr_trie_node_t on success
*/
-fr_trie_t *_fr_trie_alloc(TALLOC_CTX *ctx, fr_trie_key_t get_key, fr_free_t free_data)
+fr_trie_t *fr_trie_alloc(TALLOC_CTX *ctx, fr_trie_key_t get_key, fr_free_t free_data)
{
fr_trie_user_t *user;
fr_trie_ctx_t *uctx;
data_ctx = talloc_init_const("data_ctx");
- ft = fr_trie_alloc(NULL);
+ ft = fr_trie_alloc(NULL, NULL, NULL);
if (!ft) {
fprintf(stderr, "Failed creating trie\n");
fr_exit_now(1);
*/
typedef int (*fr_trie_key_t)(uint8_t **out, size_t *outlen, void const *data);
-#define fr_trie_alloc(_ctx) _fr_trie_alloc(_ctx, NULL, NULL)
+fr_trie_t *fr_trie_alloc(TALLOC_CTX *ctx, fr_trie_key_t get_key, fr_free_t free_node);
-#define fr_trie_generic_alloc(_ctx, _get_key, _free_data) _fr_trie_alloc(_ctx, _get_key, _free_data)
-
-fr_trie_t *_fr_trie_alloc(TALLOC_CTX *ctx, fr_trie_key_t get_key, fr_free_t free_node);
int fr_trie_insert_by_key(fr_trie_t *ft, void const *key, size_t keylen, void const *data) CC_HINT(nonnull);
void *fr_trie_lookup_by_key(fr_trie_t const *ft, void const *key, size_t keylen) CC_HINT(nonnull);
+
void *fr_trie_match_by_key(fr_trie_t const *ft, void const *key, size_t keylen) CC_HINT(nonnull);
+
void *fr_trie_remove_by_key(fr_trie_t *ft, void const *key, size_t keylen) CC_HINT(nonnull);
int fr_trie_walk(fr_trie_t *ft, void *ctx, fr_trie_walk_t callback) CC_HINT(nonnull(1,3));
return -1;
}
} else {
- MEM(inst->trie = fr_trie_alloc(inst));
+ MEM(inst->trie = fr_trie_alloc(inst, NULL, NULL));
for (i = 0; i < num; i++) {
fr_ipaddr_t *network;
*/
if ((inst->key_data_type == FR_TYPE_IPV4_ADDR) || (inst->key_data_type == FR_TYPE_IPV4_PREFIX) ||
(inst->key_data_type == FR_TYPE_IPV6_ADDR) || (inst->key_data_type == FR_TYPE_IPV6_PREFIX)) {
- MEM(inst->trie = fr_trie_alloc(inst));
+ MEM(inst->trie = fr_trie_alloc(inst, NULL, NULL));
} else {
MEM(inst->tree = fr_rb_inline_talloc_alloc(inst, rlm_csv_entry_t, node, csv_entry_cmp, NULL, 0));
}
}
} else {
- parent->subnets = fr_trie_alloc(parent);
+ parent->subnets = fr_trie_alloc(parent, NULL, NULL);
if (!parent->subnets) return -1;
}
{
fr_trie_t *states;
- MEM(states = fr_trie_alloc(ctx));
+ MEM(states = fr_trie_alloc(ctx, NULL, NULL));
if (sql_state_entries_from_table(states, sql_2011_classes) < 0) {
talloc_free(states);