From: Alan T. DeKok Date: Mon, 12 Apr 2021 16:26:40 +0000 (-0400) Subject: move to standard names X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f69e83aafce74cc179d75f26de6629977c7f44eb;p=thirdparty%2Ffreeradius-server.git move to standard names we use fr_tmp_cmp_t for the comparison function which returns "int", as not all comparison functions have been updated to return "int8_t" --- diff --git a/src/lib/util/hash.c b/src/lib/util/hash.c index f3849979b83..29d4af85c5b 100644 --- a/src/lib/util/hash.c +++ b/src/lib/util/hash.c @@ -54,9 +54,9 @@ struct fr_hash_table_s { int next_grow; int mask; - fr_hash_table_free_t free; - fr_hash_table_hash_t hash; - fr_hash_table_cmp_t cmp; + fr_free_t free; + fr_hash_t hash; + fr_tmp_cmp_t cmp; fr_hash_entry_t null; @@ -280,9 +280,9 @@ static int _fr_hash_table_free(fr_hash_table_t *ht) * Memory usage in bytes is (20/3) * number of entries. */ fr_hash_table_t *fr_hash_table_create(TALLOC_CTX *ctx, - fr_hash_table_hash_t hash_func, - fr_hash_table_cmp_t cmp_func, - fr_hash_table_free_t free_func) + fr_hash_t hash_func, + fr_tmp_cmp_t cmp_func, + fr_free_t free_func) { fr_hash_table_t *ht; diff --git a/src/lib/util/hash.h b/src/lib/util/hash.h index 58ba3273b32..8eab2a0bc38 100644 --- a/src/lib/util/hash.h +++ b/src/lib/util/hash.h @@ -27,9 +27,7 @@ RCSIDH(hash_h, "$Id$") extern "C" { #endif -#include -#include -#include +#include #include #include @@ -54,15 +52,12 @@ uint32_t fr_hash_string(char const *p); uint32_t fr_hash_case_string(char const *p); typedef struct fr_hash_table_s fr_hash_table_t; -typedef void (*fr_hash_table_free_t)(void *); -typedef uint32_t (*fr_hash_table_hash_t)(void const *); -typedef int (*fr_hash_table_cmp_t)(void const *, void const *); 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_hash_t hashNode, - fr_hash_table_cmp_t cmpNode, - fr_hash_table_free_t freeNode); + fr_hash_t hashNode, + fr_tmp_cmp_t cmpNode, + fr_free_t freeNode); int fr_hash_table_insert(fr_hash_table_t *ht, void const *data); diff --git a/src/lib/util/misc.h b/src/lib/util/misc.h index 4c175e9c4ab..967d3c334a3 100644 --- a/src/lib/util/misc.h +++ b/src/lib/util/misc.h @@ -36,6 +36,9 @@ extern "C" { #include typedef int8_t (*fr_cmp_t)(void const *a, void const *b); +typedef int (*fr_tmp_cmp_t)(void const *a, void const *b); +typedef void (*fr_free_t)(void *); +typedef uint32_t (*fr_hash_t)(void const *); /* diff --git a/src/lib/util/pair.h b/src/lib/util/pair.h index 6b591480de6..05a5b2c173c 100644 --- a/src/lib/util/pair.h +++ b/src/lib/util/pair.h @@ -263,9 +263,6 @@ fr_pair_t *fr_pair_delete(fr_pair_list_t *list, fr_pair_t *vp); /* functions for FR_TYPE_STRUCTURAL */ fr_pair_list_t *fr_pair_children(fr_pair_t *head); -/* Sorting */ -typedef int8_t (*fr_cmp_t)(void const *a, void const *b); - /** Compare two attributes using and operator. * * @return diff --git a/src/lib/util/rbtree.c b/src/lib/util/rbtree.c index f55b403c840..aad5ad5cbd3 100644 --- a/src/lib/util/rbtree.c +++ b/src/lib/util/rbtree.c @@ -42,8 +42,8 @@ struct rbtree_s { char const *type; //!< Talloc type to check elements against. size_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. + fr_tmp_cmp_t compare; //!< The comparator. + fr_free_t free; //!< Free function called when a node is freed. bool replace; //!< Allow replacements. bool lock; //!< Ensure exclusive access. @@ -159,7 +159,7 @@ static int _tree_free(rbtree_t *tree) */ rbtree_t *_rbtree_alloc(TALLOC_CTX *ctx, size_t offset, char const *type, - fr_rb_cmp_t compare, fr_rb_free_t node_free, + fr_tmp_cmp_t compare, fr_free_t node_free, int flags) { rbtree_t *tree; diff --git a/src/lib/util/rbtree.h b/src/lib/util/rbtree.h index e1d6b3a7a65..536601c6046 100644 --- a/src/lib/util/rbtree.h +++ b/src/lib/util/rbtree.h @@ -27,9 +27,7 @@ RCSIDH(rbtree_h, "$Id$") extern "C" { #endif -#include -#include -#include +#include #include #include @@ -58,9 +56,6 @@ struct fr_rb_node_s { #define RBTREE_FLAG_REPLACE (1 << 0) #define RBTREE_FLAG_LOCK (1 << 1) -typedef int (*fr_rb_cmp_t)(void const *one, void const *two); -typedef void (*fr_rb_free_t)(void *data); - /** Creates a red black that verifies elements are of a specific talloc type * * @param[in] _ctx to tie tree lifetime to. @@ -102,7 +97,7 @@ typedef void (*fr_rb_free_t)(void *data); ) rbtree_t *_rbtree_alloc(TALLOC_CTX *ctx, size_t offset, char const *type, - fr_rb_cmp_t compare, fr_rb_free_t node_free, int flags) CC_HINT(warn_unused_result); + fr_tmp_cmp_t compare, fr_free_t node_free, int flags) CC_HINT(warn_unused_result); void rbtree_unlock(rbtree_t *tree) CC_HINT(nonnull);