hash table REFACTOR improve ht val equal cb name
diff --git a/src/hash_table.c b/src/hash_table.c
index e771006..7c1266a 100644
--- a/src/hash_table.c
+++ b/src/hash_table.c
@@ -30,7 +30,7 @@
/**
* @brief Comparison callback for dictionary's hash table
*
- * Implementation of ::values_equal_cb.
+ * Implementation of ::lyht_value_equal_cb.
*/
static ly_bool
lydict_val_eq(void *val1_p, void *val2_p, ly_bool UNUSED(mod), void *cb_data)
@@ -309,7 +309,7 @@
}
struct hash_table *
-lyht_new(uint32_t size, uint16_t val_size, values_equal_cb val_equal, void *cb_data, uint16_t resize)
+lyht_new(uint32_t size, uint16_t val_size, lyht_value_equal_cb val_equal, void *cb_data, uint16_t resize)
{
struct hash_table *ht;
@@ -339,10 +339,10 @@
return ht;
}
-values_equal_cb
-lyht_set_cb(struct hash_table *ht, values_equal_cb new_val_equal)
+lyht_value_equal_cb
+lyht_set_cb(struct hash_table *ht, lyht_value_equal_cb new_val_equal)
{
- values_equal_cb prev;
+ lyht_value_equal_cb prev;
prev = ht->val_equal;
ht->val_equal = new_val_equal;
@@ -642,13 +642,13 @@
}
LY_ERR
-lyht_insert_with_resize_cb(struct hash_table *ht, void *val_p, uint32_t hash,
- values_equal_cb resize_val_equal, void **match_p)
+lyht_insert_with_resize_cb(struct hash_table *ht, void *val_p, uint32_t hash, lyht_value_equal_cb resize_val_equal,
+ void **match_p)
{
LY_ERR r, ret = LY_SUCCESS;
struct ht_rec *rec, *crec = NULL;
int32_t i;
- values_equal_cb old_val_equal = NULL;
+ lyht_value_equal_cb old_val_equal = NULL;
if (!lyht_find_first(ht, hash, &rec)) {
/* we found matching shortened hash */
@@ -732,13 +732,13 @@
}
LY_ERR
-lyht_remove_with_resize_cb(struct hash_table *ht, void *val_p, uint32_t hash, values_equal_cb resize_val_equal)
+lyht_remove_with_resize_cb(struct hash_table *ht, void *val_p, uint32_t hash, lyht_value_equal_cb resize_val_equal)
{
struct ht_rec *rec, *crec;
int32_t i;
ly_bool first_matched = 0;
LY_ERR r, ret = LY_SUCCESS;
- values_equal_cb old_val_equal;
+ lyht_value_equal_cb old_val_equal;
LY_CHECK_ERR_RET(lyht_find_first(ht, hash, &rec), LOGARG(NULL, hash), LY_ENOTFOUND); /* hash not found */
diff --git a/src/hash_table.h b/src/hash_table.h
index 2e7a511..510ac4f 100644
--- a/src/hash_table.h
+++ b/src/hash_table.h
@@ -47,7 +47,7 @@
* @param[in] cb_data User callback data.
* @return false (non-equal) or true (equal).
*/
-typedef ly_bool (*values_equal_cb)(void *val1_p, void *val2_p, ly_bool mod, void *cb_data);
+typedef ly_bool (*lyht_value_equal_cb)(void *val1_p, void *val2_p, ly_bool mod, void *cb_data);
/** reference value for 100% */
#define LYHT_HUNDRED_PERCENTAGE 100
@@ -85,7 +85,7 @@
struct hash_table {
uint32_t used; /* number of values stored in the hash table (filled records) */
uint32_t size; /* always holds 2^x == size (is power of 2), actually number of records allocated */
- values_equal_cb val_equal; /* callback for testing value equivalence */
+ lyht_value_equal_cb val_equal; /* callback for testing value equivalence */
void *cb_data; /* user data callback arbitrary value */
uint16_t resize; /* 0 - resizing is disabled, *
* 1 - enlarging is enabled, *
@@ -131,7 +131,7 @@
* @param[in] resize Whether to resize the table on too few/too many records taken.
* @return Empty hash table, NULL on error.
*/
-struct hash_table *lyht_new(uint32_t size, uint16_t val_size, values_equal_cb val_equal, void *cb_data, uint16_t resize);
+struct hash_table *lyht_new(uint32_t size, uint16_t val_size, lyht_value_equal_cb val_equal, void *cb_data, uint16_t resize);
/**
* @brief Set hash table value equal callback.
@@ -140,7 +140,7 @@
* @param[in] new_val_equal New callback for checking value equivalence.
* @return Previous callback for checking value equivalence.
*/
-values_equal_cb lyht_set_cb(struct hash_table *ht, values_equal_cb new_val_equal);
+lyht_value_equal_cb lyht_set_cb(struct hash_table *ht, lyht_value_equal_cb new_val_equal);
/**
* @brief Set hash table value equal callback user data.
@@ -219,7 +219,7 @@
* @return LY_EEXIST in case the value is already present.
* @return LY_EMEM in case of memory allocation failure.
*/
-LY_ERR lyht_insert_with_resize_cb(struct hash_table *ht, void *val_p, uint32_t hash, values_equal_cb resize_val_equal,
+LY_ERR lyht_insert_with_resize_cb(struct hash_table *ht, void *val_p, uint32_t hash, lyht_value_equal_cb resize_val_equal,
void **match_p);
/**
@@ -247,6 +247,6 @@
* @return LY_SUCCESS on success,
* @return LY_ENOTFOUND if value was not found.
*/
-LY_ERR lyht_remove_with_resize_cb(struct hash_table *ht, void *val_p, uint32_t hash, values_equal_cb resize_val_equal);
+LY_ERR lyht_remove_with_resize_cb(struct hash_table *ht, void *val_p, uint32_t hash, lyht_value_equal_cb resize_val_equal);
#endif /* LY_HASH_TABLE_H_ */
diff --git a/src/printer_lyb.c b/src/printer_lyb.c
index 2082999..800e915 100644
--- a/src/printer_lyb.c
+++ b/src/printer_lyb.c
@@ -40,7 +40,7 @@
/**
* @brief Hash table equal callback for checking hash equality only.
*
- * Implementation of ::values_equal_cb.
+ * Implementation of ::lyht_value_equal_cb.
*/
static ly_bool
lyb_hash_equal_cb(void *UNUSED(val1_p), void *UNUSED(val2_p), ly_bool UNUSED(mod), void *UNUSED(cb_data))
@@ -52,7 +52,7 @@
/**
* @brief Hash table equal callback for checking value pointer equality only.
*
- * Implementation of ::values_equal_cb.
+ * Implementation of ::lyht_value_equal_cb.
*/
static ly_bool
lyb_ptr_equal_cb(void *val1_p, void *val2_p, ly_bool UNUSED(mod), void *UNUSED(cb_data))
diff --git a/src/tree_data.c b/src/tree_data.c
index 2a29a60..2368f30 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -3469,7 +3469,7 @@
*
* @param[in] val1_p Pointer to the schema node
* @param[in] val2_p Pointer to the data node
- * Implementation of ::values_equal_cb.
+ * Implementation of ::lyht_value_equal_cb.
*/
static ly_bool
lyd_hash_table_schema_val_equal(void *val1_p, void *val2_p, ly_bool UNUSED(mod), void *UNUSED(cb_data))
@@ -3505,7 +3505,7 @@
struct lyd_node **match_p;
struct lyd_node_inner *parent;
uint32_t hash;
- values_equal_cb ht_cb;
+ lyht_value_equal_cb ht_cb;
assert(siblings && schema);
diff --git a/src/tree_data_hash.c b/src/tree_data_hash.c
index c64e281..622ce22 100644
--- a/src/tree_data_hash.c
+++ b/src/tree_data_hash.c
@@ -85,7 +85,7 @@
/**
* @brief Compare callback for values in hash table.
*
- * Implementation of ::values_equal_cb.
+ * Implementation of ::lyht_value_equal_cb.
*/
static ly_bool
lyd_hash_table_val_equal(void *val1_p, void *val2_p, ly_bool mod, void *UNUSED(cb_data))
diff --git a/src/tree_schema_helpers.c b/src/tree_schema_helpers.c
index e9397d8..2f0bf43 100644
--- a/src/tree_schema_helpers.c
+++ b/src/tree_schema_helpers.c
@@ -385,7 +385,7 @@
/**
* @brief Compare identifiers.
- * Implementation of ::values_equal_cb.
+ * Implementation of ::lyht_value_equal_cb.
*/
static ly_bool
lysp_id_cmp(void *val1, void *val2, ly_bool UNUSED(mod), void *UNUSED(cb_data))
diff --git a/src/validation.c b/src/validation.c
index fec6d97..dcf37a9 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -828,7 +828,7 @@
/**
* @brief Callback for comparing 2 list unique leaf values.
*
- * Implementation of ::values_equal_cb.
+ * Implementation of ::lyht_value_equal_cb.
*
* @param[in] cb_data 0 to compare all uniques, n to compare only n-th unique.
*/
diff --git a/src/xpath.c b/src/xpath.c
index bd66a34..26aa168 100644
--- a/src/xpath.c
+++ b/src/xpath.c
@@ -546,7 +546,7 @@
/**
* @brief Callback for checking value equality.
*
- * Implementation of ::values_equal_cb.
+ * Implementation of ::lyht_value_equal_cb.
*
* @param[in] val1_p First value.
* @param[in] val2_p Second value.