if (!node)
return NULL;
node->elem = elem;
- if (elem) tree->elem_count++;
+ tree->node_count++;
node->scope = scope;
node->ttl = ttl;
node->edge[0] = NULL;
tree->delfunc = delfunc;
tree->sizefunc = sizefunc;
tree->env = env;
- tree->elem_count = 0;
+ tree->node_count = 0;
return tree;
}
if (!node->elem) return;
tree->delfunc(tree->env, node->elem);
node->elem = NULL;
- tree->elem_count--;
}
/**
if (depth == sourcemask) {
/* update this node's scope and data */
clean_node(tree, node);
- tree->elem_count++;
node->elem = elem;
node->scope = scope;
return;
struct addrnode* root;
/** Number of elements in the tree (not always equal to number of
* nodes) */
- unsigned int elem_count;
+ unsigned int node_count;
/** Maximum prefix length we are willing to cache. */
addrlen_t max_depth;
/** External function to delete elem. Called as
*/
struct addrtree*
addrtree_create(addrlen_t max_depth, void (*delfunc)(void *, void *),
- size_t (*sizefunc)(void *), void *env, int max_elem_count);
+ size_t (*sizefunc)(void *), void *env);
/**
* Free tree and all nodes below
srand(9195); /* just some value for reproducibility */
t = addrtree_create(100, &elemfree, NULL, &env);
- count = t->elem_count;
+ count = t->node_count;
unit_assert(count == 0);
for (i = 0; i < 1000; i++) {
l = randomkey(&k, 128);
addrtree_insert(t, k, l, 64, elem, timenow + 10, timenow);
/* This should always hold because no items ever expire. They
* could be overwritten, though. */
- unit_assert( count <= t->elem_count );
- count = t->elem_count;
+ unit_assert( count <= t->node_count );
+ count = t->node_count;
free(k);
unit_assert( !addrtree_inconsistent(t) );
}
addrtree_delete(t);
unit_show_func("edns-subnet/addrtree.h", "Tree consistency with purge");
t = addrtree_create(8, &elemfree, NULL, &env);
- unit_assert(t->elem_count == 0);
+ unit_assert(t->node_count == 0);
for (i = 0; i < 1000; i++) {
l = randomkey(&k, 128);
elem = (struct reply_info *) calloc(1, sizeof(struct reply_info));