From: Arran Cudbard-Bell Date: Sun, 18 Apr 2021 15:56:56 +0000 (-0500) Subject: Remove node_ctx from rb_inline functions X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7351551df873c1b8dfd27f834398429f475d652f;p=thirdparty%2Ffreeradius-server.git Remove node_ctx from rb_inline functions Mark tree arg in fr_rb_find as const --- diff --git a/src/lib/util/rb.c b/src/lib/util/rb.c index d4ff8162c05..768711ac7ad 100644 --- a/src/lib/util/rb.c +++ b/src/lib/util/rb.c @@ -544,7 +544,7 @@ static void delete_internal(fr_rb_tree_t *tree, fr_rb_node_t *z, bool free_data) /* Find user data, returning the node * */ -static inline CC_HINT(always_inline) fr_rb_node_t *find_node(fr_rb_tree_t *tree, void const *data) +static inline CC_HINT(always_inline) fr_rb_node_t *find_node(fr_rb_tree_t const *tree, void const *data) { fr_rb_node_t *current; @@ -573,7 +573,7 @@ static inline CC_HINT(always_inline) fr_rb_node_t *find_node(fr_rb_tree_t *tree, * * @hidecallergraph */ -void *fr_rb_find(fr_rb_tree_t *tree, void const *data) +void *fr_rb_find(fr_rb_tree_t const *tree, void const *data) { fr_rb_node_t *x; diff --git a/src/lib/util/rb.h b/src/lib/util/rb.h index e3cff96dbe5..2fb2be09aac 100644 --- a/src/lib/util/rb.h +++ b/src/lib/util/rb.h @@ -146,9 +146,6 @@ struct fr_rb_tree_s { * fixed set of trees. * * @param[out] _tree to initialise. - * @param[in] _node_ctx to tie tree lifetime to. - * If ctx is freed, tree will free any nodes, calling the - * free function if set. * @param[in] _type of item being stored in the tree, e.g. fr_value_box_t. * @param[in] _field Containing the #fr_rb_node_t within item being stored. * @param[in] _data_cmp Callback to compare node data. @@ -158,9 +155,9 @@ struct fr_rb_tree_s { * - A new rbtree on success. * - NULL on failure. */ -#define fr_rb_inline_talloc_init(_tree, _node_ctx, _type, _field, _data_cmp, _data_free) \ +#define fr_rb_inline_talloc_init(_tree, _type, _field, _data_cmp, _data_free) \ _Generic((((_type *)0)->_field), \ - fr_rb_node_t: _fr_rb_init(_tree, _node_ctx, offsetof(_type, _field), #_type, _data_cmp, _data_free) \ + fr_rb_node_t: _fr_rb_init(_tree, NULL, offsetof(_type, _field), #_type, _data_cmp, _data_free) \ ) /** Initialises a red black tree @@ -172,9 +169,6 @@ struct fr_rb_tree_s { * fixed set of trees. * * @param[out] _tree to initialise. - * @param[in] _node_ctx to tie tree lifetime to. - * If ctx is freed, tree will free any nodes, calling the - * free function if set. * @param[in] _type of item being stored in the tree, e.g. fr_value_box_t. * @param[in] _field Containing the #fr_rb_node_t within item being stored. * @param[in] _data_cmp Callback to compare node data. @@ -184,9 +178,9 @@ struct fr_rb_tree_s { * - A new rbtree on success. * - NULL on failure. */ -#define fr_rb_inline_init(_tree, _node_ctx, _type, _field, _data_cmp, _data_free) \ +#define fr_rb_inline_init(_tree, _type, _field, _data_cmp, _data_free) \ _Generic((((_type *)0)->_field), \ - fr_rb_node_t: _fr_rb_init(_tree, _node_ctx, offsetof(_type, _field), NULL, _data_cmp, _data_free) \ + fr_rb_node_t: _fr_rb_init(_tree, NULL, offsetof(_type, _field), NULL, _data_cmp, _data_free) \ ) int _fr_rb_init(fr_rb_tree_t *tree, TALLOC_CTX *node_ctx, @@ -285,7 +279,7 @@ fr_rb_tree_t *_fr_rb_alloc(TALLOC_CTX *ctx, ssize_t offset, char const *type, fr_cmp_t data_cmp, fr_free_t data_free) CC_HINT(warn_unused_result); /** @hidecallergraph */ -void *fr_rb_find(fr_rb_tree_t *tree, void const *data) CC_HINT(nonnull); +void *fr_rb_find(fr_rb_tree_t const *tree, void const *data) CC_HINT(nonnull); int fr_rb_find_or_insert(void **found, fr_rb_tree_t *tree, void const *data) CC_HINT(nonnull(2,3));