From 02b0759345b2629588d300d717c8038e85e0c3e6 Mon Sep 17 00:00:00 2001 From: Arran Cudbard-Bell Date: Wed, 27 Jan 2021 02:12:58 +0000 Subject: [PATCH] Prefix rbtree types with fr_ Expose rbnode_t in public headers --- src/lib/server/cf_file.c | 4 +- src/lib/server/cf_file.h | 2 +- src/lib/server/cf_util.c | 2 +- src/lib/server/map_proc.c | 2 +- src/lib/util/rbtree.c | 140 ++++++++++++++++------------------ src/lib/util/rbtree.h | 42 ++++++---- src/modules/rlm_securid/mem.c | 4 +- src/protocols/radius/list.c | 4 +- src/protocols/radius/list.h | 2 +- src/tests/rbmonkey.c | 24 +++--- 10 files changed, 112 insertions(+), 114 deletions(-) diff --git a/src/lib/server/cf_file.c b/src/lib/server/cf_file.c index 305c0d20ef..ba0a3f95e0 100644 --- a/src/lib/server/cf_file.c +++ b/src/lib/server/cf_file.c @@ -682,7 +682,7 @@ bool cf_file_check(CONF_SECTION *cs, char const *filename, bool check_perms) typedef struct { int rcode; - rb_walker_t callback; + fr_rb_walker_t callback; CONF_SECTION *modules; } cf_file_callback_t; @@ -2397,7 +2397,7 @@ void cf_file_check_user(uid_t uid, gid_t gid) /* * See if any of the files have changed. */ -int cf_file_changed(CONF_SECTION *cs, rb_walker_t callback) +int cf_file_changed(CONF_SECTION *cs, fr_rb_walker_t callback) { CONF_SECTION *top; cf_file_callback_t cb; diff --git a/src/lib/server/cf_file.h b/src/lib/server/cf_file.h index f241a9e813..847db1227d 100644 --- a/src/lib/server/cf_file.h +++ b/src/lib/server/cf_file.h @@ -53,7 +53,7 @@ void cf_file_free(CONF_SECTION *cs); bool cf_file_check(CONF_SECTION *cs, char const *filename, bool check_perms); void cf_file_check_user(uid_t uid, gid_t gid); -int cf_file_changed(CONF_SECTION *cs, rb_walker_t callback); +int cf_file_changed(CONF_SECTION *cs, fr_rb_walker_t callback); /* * Config file writing diff --git a/src/lib/server/cf_util.c b/src/lib/server/cf_util.c index 22f4b9de23..aa0bd5e256 100644 --- a/src/lib/server/cf_util.c +++ b/src/lib/server/cf_util.c @@ -1681,7 +1681,7 @@ typedef struct { void *ctx; //!< to pass to cb. } cf_data_walk_ctx_t; -/** Wrap a cf_walker_t in an rb_walker_t +/** Wrap a cf_walker_t in an fr_rb_walker_t * * @param[in] data A CONF_DATA entry. * @param[in] uctx A cf_data_walk_ctx_t. diff --git a/src/lib/server/map_proc.c b/src/lib/server/map_proc.c index 66e378f4da..b99a25a042 100644 --- a/src/lib/server/map_proc.c +++ b/src/lib/server/map_proc.c @@ -128,7 +128,7 @@ int map_proc_register(void *mod_inst, char const *name, */ proc = map_proc_find(name); if (!proc) { - rbnode_t *node; + fr_rb_node_t *node; proc = talloc_zero(mod_inst, map_proc_t); strlcpy(proc->name, name, sizeof(proc->name)); diff --git a/src/lib/util/rbtree.c b/src/lib/util/rbtree.c index cd780a3a58..165448e47d 100644 --- a/src/lib/util/rbtree.c +++ b/src/lib/util/rbtree.c @@ -28,48 +28,35 @@ RCSID("$Id$") #include -/* Red-Black tree description */ -typedef enum { - BLACK, - RED -} node_colour_t; - -struct rbnode_s { - rbnode_t *left; //!< Left child - rbnode_t *right; //!< Right child - rbnode_t *parent; //!< Parent - node_colour_t colour; //!< Node colour (BLACK, RED) - bool being_freed; //!< Disable frees if we're currently calling - ///< a free function. - void *data; //!< data stored in node -}; - #define NIL &sentinel /* all leafs are sentinels */ -static rbnode_t sentinel = { NIL, NIL, NULL, BLACK, NULL}; +static fr_rb_node_t sentinel = { NIL, NIL, NULL, BLACK, NULL}; struct rbtree_s { #ifndef NDEBUG uint32_t magic; #endif - rbnode_t *root; - int num_elements; - rb_comparator_t compare; - rb_free_t free; - bool replace; - bool lock; - pthread_mutex_t mutex; - bool being_freed; //!< Prevent double frees in talloc_destructor. + fr_rb_node_t *root; //!< Root of the rbtree. + + size_t offset; //!< Where's the fr_rb_node_t is located in + ///< the structure being inserted. char const *type; //!< Talloc type to check elements against. - TALLOC_CTX *node_ctx; //!< Freed last by the destructor, to ensure - //!< the tree is still functional. + uint64_t num_elements; //!< How many elements are inside the tree. + fr_rb_cmp_t compare; //!< The comparator. + fr_rb_free_t free; //!< Free function called when a node is freed. + + bool replace; //!< Allow replacements. + bool lock; //!< Ensure exclusive access. + pthread_mutex_t mutex; //!< Mutex to ensure exclusive access. + + bool being_freed; //!< Prevent double frees in talloc_destructor. }; #ifndef NDEBUG # define RBTREE_MAGIC (0x5ad09c42) #endif -static inline void rbtree_free_data(rbtree_t *tree, rbnode_t *node) +static inline void rbtree_free_data(rbtree_t *tree, fr_rb_node_t *node) { if (!tree->free || unlikely(node->being_freed)) return; node->being_freed = true; @@ -80,9 +67,9 @@ static inline void rbtree_free_data(rbtree_t *tree, rbnode_t *node) /** Walks the tree to delete all nodes Does NOT re-balance it! * */ -static void free_walker(rbtree_t *tree, rbnode_t *x) +static void free_walker(rbtree_t *tree, fr_rb_node_t *x) { - (void) talloc_get_type_abort(x, rbnode_t); + (void) talloc_get_type_abort(x, fr_rb_node_t); if (x->left != NIL) free_walker(tree, x->left); if (x->right != NIL) free_walker(tree, x->right); @@ -152,24 +139,26 @@ static int _tree_free(rbtree_t *tree) * * @note Due to the node memory being allocated from a different pool to the main */ -rbtree_t *_rbtree_alloc(TALLOC_CTX *ctx, rb_comparator_t compare, - char const *type, rb_free_t node_free, int flags) +rbtree_t *_rbtree_alloc(TALLOC_CTX *ctx, fr_rb_cmp_t compare, + char const *type, fr_rb_free_t node_free, int flags) { rbtree_t *tree; - if (!compare) return NULL; - - tree = talloc_zero(ctx, rbtree_t); + tree = talloc(ctx, rbtree_t); if (!tree) return NULL; + *tree = (rbtree_t) { #ifndef NDEBUG - tree->magic = RBTREE_MAGIC; + .magic = RBTREE_MAGIC, #endif - tree->root = NIL; - tree->compare = compare; - tree->replace = (flags & RBTREE_FLAG_REPLACE) != 0 ? true : false; - tree->lock = (flags & RBTREE_FLAG_LOCK) != 0 ? true : false; - tree->node_ctx = talloc_new(tree); + .root = NIL, +// .offset = offset, + .type = type, + .compare = compare, + .replace = ((flags & RBTREE_FLAG_REPLACE) != 0), + .lock = ((flags & RBTREE_FLAG_LOCK) != 0), + .free = node_free + }; if (tree->lock) pthread_mutex_init(&tree->mutex, NULL); talloc_set_destructor(tree, _tree_free); @@ -182,10 +171,10 @@ rbtree_t *_rbtree_alloc(TALLOC_CTX *ctx, rb_comparator_t compare, /** Rotate Node x to left * */ -static void rotate_left(rbtree_t *tree, rbnode_t *x) +static void rotate_left(rbtree_t *tree, fr_rb_node_t *x) { - rbnode_t *y = x->right; + fr_rb_node_t *y = x->right; /* establish x->right link */ x->right = y->left; @@ -211,9 +200,9 @@ static void rotate_left(rbtree_t *tree, rbnode_t *x) /** Rotate Node x to right * */ -static void rotate_right(rbtree_t *tree, rbnode_t *x) +static void rotate_right(rbtree_t *tree, fr_rb_node_t *x) { - rbnode_t *y = x->left; + fr_rb_node_t *y = x->left; /* establish x->left link */ x->left = y->right; @@ -239,13 +228,13 @@ static void rotate_right(rbtree_t *tree, rbnode_t *x) /** Maintain red-black tree balance after inserting node x * */ -static void insert_fixup(rbtree_t *tree, rbnode_t *x) +static void insert_fixup(rbtree_t *tree, fr_rb_node_t *x) { /* check RED-BLACK properties */ while ((x != tree->root) && (x->parent->colour == RED)) { /* we have a violation */ if (x->parent == x->parent->parent->left) { - rbnode_t *y = x->parent->parent->right; + fr_rb_node_t *y = x->parent->parent->right; if (y->colour == RED) { /* uncle is RED */ @@ -270,7 +259,7 @@ static void insert_fixup(rbtree_t *tree, rbnode_t *x) } else { /* mirror image of above code */ - rbnode_t *y = x->parent->parent->left; + fr_rb_node_t *y = x->parent->parent->left; if (y->colour == RED) { /* uncle is RED */ @@ -299,9 +288,9 @@ static void insert_fixup(rbtree_t *tree, rbnode_t *x) /** Insert an element into the tree * */ -rbnode_t *rbtree_insert_node(rbtree_t *tree, void *data) +fr_rb_node_t *rbtree_insert_node(rbtree_t *tree, void *data) { - rbnode_t *current, *parent, *x; + fr_rb_node_t *current, *parent, *x; if (unlikely(tree->being_freed)) return NULL; @@ -344,7 +333,7 @@ rbnode_t *rbtree_insert_node(rbtree_t *tree, void *data) } /* setup new node */ - x = talloc_zero(tree->node_ctx, rbnode_t); + x = talloc_zero(tree, fr_rb_node_t); if (!x) { fr_strerror_const("No memory for new rbtree node"); if (tree->lock) pthread_mutex_unlock(&tree->mutex); @@ -391,12 +380,12 @@ bool rbtree_insert(rbtree_t *tree, void const *data) /** Maintain RED-BLACK tree balance after deleting node x * */ -static void delete_fixup(rbtree_t *tree, rbnode_t *x, rbnode_t *parent) +static void delete_fixup(rbtree_t *tree, fr_rb_node_t *x, fr_rb_node_t *parent) { while (x != tree->root && x->colour == BLACK) { if (x == parent->left) { - rbnode_t *w = parent->right; + fr_rb_node_t *w = parent->right; if (w->colour == RED) { w->colour = BLACK; parent->colour = RED; /* parent != NIL? */ @@ -423,7 +412,7 @@ static void delete_fixup(rbtree_t *tree, rbnode_t *x, rbnode_t *parent) x = tree->root; } } else { - rbnode_t *w = parent->left; + fr_rb_node_t *w = parent->left; if (w->colour == RED) { w->colour = BLACK; parent->colour = RED; /* parent != NIL? */ @@ -457,10 +446,10 @@ static void delete_fixup(rbtree_t *tree, rbnode_t *x, rbnode_t *parent) /** Delete an element (z) from the tree * */ -static void rbtree_delete_internal(rbtree_t *tree, rbnode_t *z, bool skiplock) +static void rbtree_delete_internal(rbtree_t *tree, fr_rb_node_t *z, bool skiplock) { - rbnode_t *x, *y; - rbnode_t *parent; + fr_rb_node_t *x, *y; + fr_rb_node_t *parent; if (!z || z == NIL) return; @@ -508,7 +497,7 @@ static void rbtree_delete_internal(rbtree_t *tree, rbnode_t *z, bool skiplock) } /* - * The user structure in y->data MAy include a + * The user structure in y->data May include a * pointer to y. In that case, we CANNOT delete * y. Instead, we copy z (which is now in the * tree) to y, and fix up the parent/child @@ -542,7 +531,7 @@ static void rbtree_delete_internal(rbtree_t *tree, rbnode_t *z, bool skiplock) } } -void rbtree_delete(rbtree_t *tree, rbnode_t *z) +void rbtree_delete(rbtree_t *tree, fr_rb_node_t *z) { if (unlikely(tree->being_freed) || unlikely(z->being_freed)) return; @@ -555,7 +544,7 @@ void rbtree_delete(rbtree_t *tree, rbnode_t *z) */ bool rbtree_deletebydata(rbtree_t *tree, void const *data) { - rbnode_t *node; + fr_rb_node_t *node; if (unlikely(tree->being_freed)) return false; @@ -571,9 +560,9 @@ bool rbtree_deletebydata(rbtree_t *tree, void const *data) /* Find user data, returning the node * */ -rbnode_t *rbtree_find(rbtree_t *tree, void const *data) +fr_rb_node_t *rbtree_find(rbtree_t *tree, void const *data) { - rbnode_t *current; + fr_rb_node_t *current; if (unlikely(tree->being_freed)) return NULL; @@ -602,7 +591,7 @@ rbnode_t *rbtree_find(rbtree_t *tree, void const *data) */ void *rbtree_finddata(rbtree_t *tree, void const *data) { - rbnode_t *x; + fr_rb_node_t *x; if (unlikely(tree->being_freed)) return NULL; @@ -617,10 +606,10 @@ void *rbtree_finddata(rbtree_t *tree, void const *data) * We call ourselves recursively for each function, but that's OK, * as the stack is only log(N) deep, which is ~12 entries deep. */ -static int walk_node_pre_order(rbnode_t *x, rb_walker_t compare, void *uctx) +static int walk_node_pre_order(fr_rb_node_t *x, fr_rb_walker_t compare, void *uctx) { - int ret; - rbnode_t *left, *right; + int ret; + fr_rb_node_t *left, *right; left = x->left; right = x->right; @@ -638,16 +627,16 @@ static int walk_node_pre_order(rbnode_t *x, rb_walker_t compare, void *uctx) if (ret != 0) return ret; } - return 0; /* we know everything returned zero */ + return 0;/* we know everything returned zero */ } /** rbtree_in_order * */ -static int walk_node_in_order(rbnode_t *x, rb_walker_t compare, void *uctx) +static int walk_node_in_order(fr_rb_node_t *x, fr_rb_walker_t compare, void *uctx) { int ret; - rbnode_t *right; + fr_rb_node_t *right; if (x->left != NIL) { ret = walk_node_in_order(x->left, compare, uctx); @@ -671,7 +660,7 @@ static int walk_node_in_order(rbnode_t *x, rb_walker_t compare, void *uctx) /** rbtree_post_order * */ -static int walk_node_post_order(rbnode_t *x, rb_walker_t compare, void *uctx) +static int walk_node_post_order(fr_rb_node_t *x, fr_rb_walker_t compare, void *uctx) { int ret; @@ -691,7 +680,6 @@ static int walk_node_post_order(rbnode_t *x, rb_walker_t compare, void *uctx) return 0; /* we know everything returned zero */ } - /** rbtree_delete_order * * This executes an rbtree_in_order-like walk that adapts to changes in the @@ -705,9 +693,9 @@ static int walk_node_post_order(rbnode_t *x, rb_walker_t compare, void *uctx) * 1 - delete the node and stop walking * 2 - delete the node and continue walking */ -static int walk_delete_order(rbtree_t *tree, rb_walker_t compare, void *uctx) +static int walk_delete_order(rbtree_t *tree, fr_rb_walker_t compare, void *uctx) { - rbnode_t *solid, *x; + fr_rb_node_t *solid, *x; int ret = 0; /* Keep track of last node that refused deletion. */ @@ -758,7 +746,7 @@ static int walk_delete_order(rbtree_t *tree, rb_walker_t compare, void *uctx) * The compare function should return 0 to continue walking. * Any other value stops the walk, and is returned. */ -int rbtree_walk(rbtree_t *tree, rb_order_t order, rb_walker_t compare, void *uctx) +int rbtree_walk(rbtree_t *tree, fr_rb_order_t order, fr_rb_walker_t compare, void *uctx) { int ret; @@ -820,7 +808,7 @@ static int _flatten_cb(void *data, void *uctx) * @return * - The number of elements in the tree. */ -uint32_t rbtree_flatten(TALLOC_CTX *ctx, void **out[], rbtree_t *tree, rb_order_t order) +uint32_t rbtree_flatten(TALLOC_CTX *ctx, void **out[], rbtree_t *tree, fr_rb_order_t order) { uint32_t num = rbtree_num_elements(tree); rbtree_flatten_ctx_t uctx; @@ -842,7 +830,7 @@ uint32_t rbtree_flatten(TALLOC_CTX *ctx, void **out[], rbtree_t *tree, rb_order_ /* * Given a Node, return the data. */ -void *rbtree_node2data(UNUSED rbtree_t *tree, rbnode_t *node) +void *rbtree_node2data(UNUSED rbtree_t *tree, fr_rb_node_t *node) { if (!node) return NULL; diff --git a/src/lib/util/rbtree.h b/src/lib/util/rbtree.h index 0cfe7d4071..8e4bda37c0 100644 --- a/src/lib/util/rbtree.h +++ b/src/lib/util/rbtree.h @@ -36,7 +36,6 @@ extern "C" { /* rbtree.c */ typedef struct rbtree_s rbtree_t; -typedef struct rbnode_s rbnode_t; /* callback order for walking */ typedef enum { @@ -44,15 +43,32 @@ typedef enum { RBTREE_IN_ORDER, RBTREE_POST_ORDER, RBTREE_DELETE_ORDER -} rb_order_t; +} fr_rb_order_t; + +/* Red-Black tree description */ +typedef enum { + BLACK, + RED +} fr_rb_colour_t; + +typedef struct fr_rb_node_s fr_rb_node_t; +struct fr_rb_node_s { + fr_rb_node_t *left; //!< Left child + fr_rb_node_t *right; //!< Right child + fr_rb_node_t *parent; //!< Parent + fr_rb_colour_t colour; //!< Node colour (BLACK, RED) + bool being_freed; //!< Disable frees if we're currently calling + ///< a free function. + void *data; //!< data stored in node +}; #define RBTREE_FLAG_NONE (0) #define RBTREE_FLAG_REPLACE (1 << 0) #define RBTREE_FLAG_LOCK (1 << 1) -typedef int (*rb_comparator_t)(void const *one, void const *two); -typedef int (*rb_walker_t)(void *data, void *uctx); -typedef void (*rb_free_t)(void *data); +typedef int (*fr_rb_cmp_t)(void const *one, void const *two); +typedef int (*fr_rb_walker_t)(void *data, void *uctx); +typedef void (*fr_rb_free_t)(void *data); #ifndef STABLE_COMPARE /* @@ -100,29 +116,29 @@ typedef void (*rb_free_t)(void *data); #define rbtree_alloc(_ctx, _cmp, _node_free, _flags) \ _rbtree_alloc(_ctx, _cmp, NULL, _node_free, _flags) -rbtree_t *_rbtree_alloc(TALLOC_CTX *ctx, rb_comparator_t compare, - char const *type, rb_free_t node_free, int flags); +rbtree_t *_rbtree_alloc(TALLOC_CTX *ctx, fr_rb_cmp_t compare, + char const *type, fr_rb_free_t node_free, int flags); void rbtree_node_talloc_free(void *data); bool rbtree_insert(rbtree_t *tree, void const *data); -rbnode_t *rbtree_insert_node(rbtree_t *tree, void *data); +fr_rb_node_t *rbtree_insert_node(rbtree_t *tree, void *data); -void rbtree_delete(rbtree_t *tree, rbnode_t *z); +void rbtree_delete(rbtree_t *tree, fr_rb_node_t *z); bool rbtree_deletebydata(rbtree_t *tree, void const *data); -rbnode_t *rbtree_find(rbtree_t *tree, void const *data); +fr_rb_node_t *rbtree_find(rbtree_t *tree, void const *data); /** @hidecallergraph */ void *rbtree_finddata(rbtree_t *tree, void const *data); uint32_t rbtree_num_elements(rbtree_t *tree); -uint32_t rbtree_flatten(TALLOC_CTX *ctx, void **out[], rbtree_t *tree, rb_order_t order); +uint32_t rbtree_flatten(TALLOC_CTX *ctx, void **out[], rbtree_t *tree, fr_rb_order_t order); -void *rbtree_node2data(rbtree_t *tree, rbnode_t *node); +void *rbtree_node2data(rbtree_t *tree, fr_rb_node_t *node); /* * The callback should be declared as: @@ -140,7 +156,7 @@ void *rbtree_node2data(rbtree_t *tree, rbnode_t *node); * or 2 to delete the current node and continue. This may be * used to batch-delete select nodes from a locked rbtree. */ -int rbtree_walk(rbtree_t *tree, rb_order_t order, rb_walker_t compare, void *uctx); +int rbtree_walk(rbtree_t *tree, fr_rb_order_t order, fr_rb_walker_t compare, void *uctx); #ifdef __cplusplus } diff --git a/src/modules/rlm_securid/mem.c b/src/modules/rlm_securid/mem.c index e7c8295a8d..eb44a3d15a 100644 --- a/src/modules/rlm_securid/mem.c +++ b/src/modules/rlm_securid/mem.c @@ -229,7 +229,7 @@ SECURID_SESSION *securid_sessionlist_find(rlm_securid_t *inst, request_t *reques /************ private functions *************/ static SECURID_SESSION *securid_sessionlist_delete(rlm_securid_t *inst, SECURID_SESSION *session) { - rbnode_t *node; + fr_rb_node_t *node; node = rbtree_find(inst->session_tree, session); if (!node) return NULL; @@ -274,7 +274,7 @@ static void securid_sessionlist_clean_expired(rlm_securid_t *inst, request_t *re */ while((session = inst->session_head)) { if ((timestamp - session->timestamp) > inst->timer_limit) { - rbnode_t *node; + fr_rb_node_t *node; node = rbtree_find(inst->session_tree, session); fr_assert(node != NULL); rbtree_delete(inst->session_tree, node); diff --git a/src/protocols/radius/list.c b/src/protocols/radius/list.c index 5952e1116d..acd50b34f0 100644 --- a/src/protocols/radius/list.c +++ b/src/protocols/radius/list.c @@ -379,7 +379,7 @@ fr_radius_packet_t *fr_packet_list_find_byreply(fr_packet_list_t *pl, fr_radius_ bool fr_packet_list_yank(fr_packet_list_t *pl, fr_radius_packet_t *request) { - rbnode_t *node; + fr_rb_node_t *node; if (!pl || !request) return false; @@ -671,7 +671,7 @@ bool fr_packet_list_id_free(fr_packet_list_t *pl, * 1 means delete current node and stop * 2 means delete current node and continue */ -int fr_packet_list_walk(fr_packet_list_t *pl, rb_walker_t callback, void *uctx) +int fr_packet_list_walk(fr_packet_list_t *pl, fr_rb_walker_t callback, void *uctx) { if (!pl || !callback) return 0; diff --git a/src/protocols/radius/list.h b/src/protocols/radius/list.h index 8c4a48bbf4..f6647b147c 100644 --- a/src/protocols/radius/list.h +++ b/src/protocols/radius/list.h @@ -54,7 +54,7 @@ bool fr_packet_list_socket_add(fr_packet_list_t *pl, int sockfd, int proto, bool fr_packet_list_socket_del(fr_packet_list_t *pl, int sockfd); bool fr_packet_list_socket_freeze(fr_packet_list_t *pl, int sockfd); bool fr_packet_list_socket_thaw(fr_packet_list_t *pl, int sockfd); -int fr_packet_list_walk(fr_packet_list_t *pl, rb_walker_t callback, void *uctx); +int fr_packet_list_walk(fr_packet_list_t *pl, fr_rb_walker_t callback, void *uctx); int fr_packet_list_fd_set(fr_packet_list_t *pl, fd_set *set); fr_radius_packet_t *fr_packet_list_recv(fr_packet_list_t *pl, fd_set *set, uint32_t max_attributes, bool require_ma); diff --git a/src/tests/rbmonkey.c b/src/tests/rbmonkey.c index b5ee28de69..278ba23fe9 100644 --- a/src/tests/rbmonkey.c +++ b/src/tests/rbmonkey.c @@ -9,17 +9,11 @@ * This needs to be kept in lockstep with rbtree.c */ -/* RED-BLACK tree description */ -typedef enum { - BLACK, - RED -} node_colour_t; - struct rbnode_s { - rbnode_t *left; //!< left child - rbnode_t *right; //!< right child - rbnode_t *parent; //!< Parent - node_colour_t colour; //!< Node colour (BLACK, RED) + fr_rb_node_t *left; //!< left child + fr_rb_node_t *right; //!< right child + fr_rb_node_t *parent; //!< Parent + fr_rb_colour_t colour; //!< Node colour (BLACK, RED) void *data; //!< data stored in node }; @@ -27,17 +21,17 @@ struct rbtree_s { #ifndef NDEBUG uint32_t magic; #endif - rbnode_t *root; + fr_rb_node_t *root; int num_elements; - rb_comparator_t compare; - rb_free_t free; + fr_rb_cmp_t compare; + fr_rb_free_t free; bool replace; bool lock; pthread_mutex_t mutex; }; /* Storage for the NIL pointer. */ -static rbnode_t *NIL; +static fr_rb_node_t *NIL; static int comp(void const *a, void const *b) { @@ -86,7 +80,7 @@ static int filter_cb(void *i, void *uctx) */ static int rbcount(rbtree_t *t) { - rbnode_t *n; + fr_rb_node_t *n; int count, count_expect; count_expect = -1; -- 2.47.2