hash table REFACTOR use unified struct names
diff --git a/src/common.h b/src/common.h
index 704a4e7..ad7a040 100644
--- a/src/common.h
+++ b/src/common.h
@@ -314,7 +314,7 @@
* @brief Context of the YANG schemas
*/
struct ly_ctx {
- struct dict_table dict; /**< dictionary to effectively store strings used in the context related structures */
+ struct ly_dict dict; /**< dictionary to effectively store strings used in the context related structures */
struct ly_set search_paths; /**< set of directories where to search for schema's imports/includes */
struct ly_set list; /**< set of loaded YANG schemas */
ly_module_imp_clb imp_clb; /**< optional callback for retrieving missing included or imported models */
diff --git a/src/diff.c b/src/diff.c
index a9292df..d4f3f20 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -659,7 +659,7 @@
*/
static LY_ERR
lyd_diff_find_match(const struct lyd_node *siblings, const struct lyd_node *target, ly_bool defaults,
- struct hash_table **dup_inst_ht, struct lyd_node **match)
+ struct ly_ht **dup_inst_ht, struct lyd_node **match)
{
LY_ERR r;
@@ -733,7 +733,7 @@
const struct lyd_node *iter_first, *iter_second;
struct lyd_node *match_second, *match_first;
struct lyd_diff_userord *userord = NULL, *userord_item;
- struct hash_table *dup_inst_first = NULL, *dup_inst_second = NULL;
+ struct ly_ht *dup_inst_first = NULL, *dup_inst_second = NULL;
LY_ARRAY_COUNT_TYPE u;
enum lyd_diff_op op;
const char *orig_default;
@@ -1084,14 +1084,14 @@
*/
static LY_ERR
lyd_diff_apply_r(struct lyd_node **first_node, struct lyd_node *parent_node, const struct lyd_node *diff_node,
- lyd_diff_cb diff_cb, void *cb_data, struct hash_table **dup_inst)
+ lyd_diff_cb diff_cb, void *cb_data, struct ly_ht **dup_inst)
{
LY_ERR ret;
struct lyd_node *match, *diff_child;
const char *str_val, *meta_str;
enum lyd_diff_op op;
struct lyd_meta *meta;
- struct hash_table *child_dup_inst = NULL;
+ struct ly_ht *child_dup_inst = NULL;
const struct ly_ctx *ctx = LYD_CTX(diff_node);
/* read all the valid attributes */
@@ -1247,7 +1247,7 @@
lyd_diff_cb diff_cb, void *cb_data)
{
const struct lyd_node *root;
- struct hash_table *dup_inst = NULL;
+ struct ly_ht *dup_inst = NULL;
LY_ERR ret = LY_SUCCESS;
LY_LIST_FOR(diff, root) {
@@ -1762,12 +1762,12 @@
*/
static LY_ERR
lyd_diff_merge_r(const struct lyd_node *src_diff, struct lyd_node *diff_parent, lyd_diff_cb diff_cb, void *cb_data,
- struct hash_table **dup_inst, uint16_t options, struct lyd_node **diff)
+ struct ly_ht **dup_inst, uint16_t options, struct lyd_node **diff)
{
LY_ERR ret = LY_SUCCESS;
struct lyd_node *child, *diff_node = NULL;
enum lyd_diff_op src_op, cur_op;
- struct hash_table *child_dup_inst = NULL;
+ struct ly_ht *child_dup_inst = NULL;
/* get source node operation */
LY_CHECK_RET(lyd_diff_get_op(src_diff, &src_op));
@@ -1873,7 +1873,7 @@
lyd_diff_cb diff_cb, void *cb_data, uint16_t options)
{
const struct lyd_node *src_root;
- struct hash_table *dup_inst = NULL;
+ struct ly_ht *dup_inst = NULL;
LY_ERR ret = LY_SUCCESS;
LY_LIST_FOR(src_diff, src_root) {
@@ -1896,7 +1896,7 @@
lyd_diff_cb diff_cb, void *cb_data, uint16_t options)
{
LY_ERR ret;
- struct hash_table *dup_inst = NULL;
+ struct ly_ht *dup_inst = NULL;
if (!src_sibling) {
return LY_SUCCESS;
diff --git a/src/hash_table.c b/src/hash_table.c
index f2e17ef..90915f0 100644
--- a/src/hash_table.c
+++ b/src/hash_table.c
@@ -37,8 +37,8 @@
{
LY_CHECK_ARG_RET(NULL, val1_p, val2_p, cb_data, 0);
- const char *str1 = ((struct dict_rec *)val1_p)->value;
- const char *str2 = ((struct dict_rec *)val2_p)->value;
+ const char *str1 = ((struct ly_dict_rec *)val1_p)->value;
+ const char *str2 = ((struct ly_dict_rec *)val2_p)->value;
LY_CHECK_ERR_RET(!str1, LOGARG(NULL, val1_p), 0);
LY_CHECK_ERR_RET(!str2, LOGARG(NULL, val2_p), 0);
@@ -51,33 +51,33 @@
}
void
-lydict_init(struct dict_table *dict)
+lydict_init(struct ly_dict *dict)
{
LY_CHECK_ARG_RET(NULL, dict, );
- dict->hash_tab = lyht_new(LYDICT_MIN_SIZE, sizeof(struct dict_rec), lydict_val_eq, NULL, 1);
+ dict->hash_tab = lyht_new(LYDICT_MIN_SIZE, sizeof(struct ly_dict_rec), lydict_val_eq, NULL, 1);
LY_CHECK_ERR_RET(!dict->hash_tab, LOGINT(NULL), );
pthread_mutex_init(&dict->lock, NULL);
}
void
-lydict_clean(struct dict_table *dict)
+lydict_clean(struct ly_dict *dict)
{
- struct dict_rec *dict_rec = NULL;
- struct ht_rec *rec = NULL;
+ struct ly_dict_rec *dict_rec = NULL;
+ struct ly_ht_rec *rec = NULL;
LY_CHECK_ARG_RET(NULL, dict, );
for (uint32_t i = 0; i < dict->hash_tab->size; i++) {
/* get ith record */
- rec = (struct ht_rec *)&dict->hash_tab->recs[i * dict->hash_tab->rec_size];
+ rec = (struct ly_ht_rec *)&dict->hash_tab->recs[i * dict->hash_tab->rec_size];
if (rec->hits == 1) {
/*
* this should not happen, all records inserted into
* dictionary are supposed to be removed using lydict_remove()
* before calling lydict_clean()
*/
- dict_rec = (struct dict_rec *)rec->val;
+ dict_rec = (struct ly_dict_rec *)rec->val;
LOGWRN(NULL, "String \"%s\" not freed from the dictionary, refcount %d", dict_rec->value, dict_rec->refcount);
/* if record wasn't removed before free string allocated for that record */
#ifdef NDEBUG
@@ -137,8 +137,8 @@
{
LY_CHECK_ARG_RET(NULL, val1_p, val2_p, 0);
- const char *str1 = ((struct dict_rec *)val1_p)->value;
- const char *str2 = ((struct dict_rec *)val2_p)->value;
+ const char *str1 = ((struct ly_dict_rec *)val1_p)->value;
+ const char *str2 = ((struct ly_dict_rec *)val2_p)->value;
LY_CHECK_ERR_RET(!str1, LOGARG(NULL, val1_p), 0);
LY_CHECK_ERR_RET(!str2, LOGARG(NULL, val2_p), 0);
@@ -162,7 +162,7 @@
LY_ERR ret = LY_SUCCESS;
size_t len;
uint32_t hash;
- struct dict_rec rec, *match = NULL;
+ struct ly_dict_rec rec, *match = NULL;
char *val_p;
if (!ctx || !value) {
@@ -215,7 +215,7 @@
dict_insert(const struct ly_ctx *ctx, char *value, size_t len, ly_bool zerocopy, const char **str_p)
{
LY_ERR ret = LY_SUCCESS;
- struct dict_rec *match = NULL, rec;
+ struct ly_dict_rec *match = NULL, rec;
uint32_t hash;
LOGDBG(LY_LDGDICT, "inserting \"%.*s\"", (int)len, value);
@@ -304,16 +304,16 @@
return result;
}
-struct ht_rec *
+struct ly_ht_rec *
lyht_get_rec(unsigned char *recs, uint16_t rec_size, uint32_t idx)
{
- return (struct ht_rec *)&recs[idx * rec_size];
+ return (struct ly_ht_rec *)&recs[idx * rec_size];
}
-struct hash_table *
+struct ly_ht *
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;
+ struct ly_ht *ht;
/* check that 2^x == size (power of 2) */
assert(size && !(size & (size - 1)));
@@ -334,7 +334,7 @@
ht->cb_data = cb_data;
ht->resize = resize;
- ht->rec_size = (sizeof(struct ht_rec) - 1) + val_size;
+ ht->rec_size = (sizeof(struct ly_ht_rec) - 1) + val_size;
/* allocate the records correctly */
ht->recs = calloc(size, ht->rec_size);
LY_CHECK_ERR_RET(!ht->recs, free(ht); LOGMEM(NULL), NULL);
@@ -343,7 +343,7 @@
}
lyht_value_equal_cb
-lyht_set_cb(struct hash_table *ht, lyht_value_equal_cb new_val_equal)
+lyht_set_cb(struct ly_ht *ht, lyht_value_equal_cb new_val_equal)
{
lyht_value_equal_cb prev;
@@ -353,7 +353,7 @@
}
void *
-lyht_set_cb_data(struct hash_table *ht, void *new_cb_data)
+lyht_set_cb_data(struct ly_ht *ht, void *new_cb_data)
{
void *prev;
@@ -362,14 +362,14 @@
return prev;
}
-struct hash_table *
-lyht_dup(const struct hash_table *orig)
+struct ly_ht *
+lyht_dup(const struct ly_ht *orig)
{
- struct hash_table *ht;
+ struct ly_ht *ht;
LY_CHECK_ARG_RET(NULL, orig, NULL);
- ht = lyht_new(orig->size, orig->rec_size - (sizeof(struct ht_rec) - 1), orig->val_equal, orig->cb_data, orig->resize ? 1 : 0);
+ ht = lyht_new(orig->size, orig->rec_size - (sizeof(struct ly_ht_rec) - 1), orig->val_equal, orig->cb_data, orig->resize ? 1 : 0);
if (!ht) {
return NULL;
}
@@ -381,9 +381,9 @@
}
void
-lyht_free(struct hash_table *ht, void (*val_free)(void *val_p))
+lyht_free(struct ly_ht *ht, void (*val_free)(void *val_p))
{
- struct ht_rec *rec;
+ struct ly_ht_rec *rec;
uint32_t i;
if (!ht) {
@@ -410,9 +410,9 @@
* @return LY_ERR value.
*/
static LY_ERR
-lyht_resize(struct hash_table *ht, int operation)
+lyht_resize(struct ly_ht *ht, int operation)
{
- struct ht_rec *rec;
+ struct ly_ht_rec *rec;
unsigned char *old_recs;
uint32_t i, old_size;
@@ -460,9 +460,9 @@
* @return LY_ENOTFOUND hash not found, returned the record where it would be inserted.
*/
static LY_ERR
-lyht_find_first(struct hash_table *ht, uint32_t hash, struct ht_rec **rec_p)
+lyht_find_first(struct ly_ht *ht, uint32_t hash, struct ly_ht_rec **rec_p)
{
- struct ht_rec *rec;
+ struct ly_ht_rec *rec;
uint32_t i, idx;
if (rec_p) {
@@ -512,9 +512,9 @@
* @return LY_ENOTFOUND when hash collision not found, \p last points to the record where it would be inserted.
*/
static LY_ERR
-lyht_find_collision(struct hash_table *ht, struct ht_rec **last, struct ht_rec *first)
+lyht_find_collision(struct ly_ht *ht, struct ly_ht_rec **last, struct ly_ht_rec *first)
{
- struct ht_rec *empty = NULL;
+ struct ly_ht_rec *empty = NULL;
uint32_t i, idx;
assert(last && *last);
@@ -565,10 +565,10 @@
* @return LY_SUCCESS if record was found.
*/
static LY_ERR
-lyht_find_rec(struct hash_table *ht, void *val_p, uint32_t hash, ly_bool mod, struct ht_rec **crec_p, uint32_t *col,
- struct ht_rec **rec_p)
+lyht_find_rec(struct ly_ht *ht, void *val_p, uint32_t hash, ly_bool mod, struct ly_ht_rec **crec_p, uint32_t *col,
+ struct ly_ht_rec **rec_p)
{
- struct ht_rec *rec, *crec;
+ struct ly_ht_rec *rec, *crec;
uint32_t i, c;
LY_ERR r;
@@ -622,9 +622,9 @@
}
LY_ERR
-lyht_find(struct hash_table *ht, void *val_p, uint32_t hash, void **match_p)
+lyht_find(struct ly_ht *ht, void *val_p, uint32_t hash, void **match_p)
{
- struct ht_rec *rec;
+ struct ly_ht_rec *rec;
lyht_find_rec(ht, val_p, hash, 0, NULL, NULL, &rec);
@@ -635,10 +635,10 @@
}
LY_ERR
-lyht_find_next_with_collision_cb(struct hash_table *ht, void *val_p, uint32_t hash,
+lyht_find_next_with_collision_cb(struct ly_ht *ht, void *val_p, uint32_t hash,
lyht_value_equal_cb collision_val_equal, void **match_p)
{
- struct ht_rec *rec, *crec;
+ struct ly_ht_rec *rec, *crec;
uint32_t i, c;
LY_ERR r;
@@ -681,17 +681,17 @@
}
LY_ERR
-lyht_find_next(struct hash_table *ht, void *val_p, uint32_t hash, void **match_p)
+lyht_find_next(struct ly_ht *ht, void *val_p, uint32_t hash, void **match_p)
{
return lyht_find_next_with_collision_cb(ht, val_p, hash, NULL, match_p);
}
LY_ERR
-lyht_insert_with_resize_cb(struct hash_table *ht, void *val_p, uint32_t hash, lyht_value_equal_cb resize_val_equal,
+lyht_insert_with_resize_cb(struct ly_ht *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;
+ struct ly_ht_rec *rec, *crec = NULL;
int32_t i;
lyht_value_equal_cb old_val_equal = NULL;
@@ -732,7 +732,7 @@
}
rec->hash = hash;
rec->hits = 1;
- memcpy(&rec->val, val_p, ht->rec_size - (sizeof(struct ht_rec) - 1));
+ memcpy(&rec->val, val_p, ht->rec_size - (sizeof(struct ly_ht_rec) - 1));
if (match_p) {
*match_p = (void *)&rec->val;
}
@@ -774,15 +774,15 @@
}
LY_ERR
-lyht_insert(struct hash_table *ht, void *val_p, uint32_t hash, void **match_p)
+lyht_insert(struct ly_ht *ht, void *val_p, uint32_t hash, void **match_p)
{
return lyht_insert_with_resize_cb(ht, val_p, hash, NULL, match_p);
}
LY_ERR
-lyht_remove_with_resize_cb(struct hash_table *ht, void *val_p, uint32_t hash, lyht_value_equal_cb resize_val_equal)
+lyht_remove_with_resize_cb(struct ly_ht *ht, void *val_p, uint32_t hash, lyht_value_equal_cb resize_val_equal)
{
- struct ht_rec *rec, *crec;
+ struct ly_ht_rec *rec, *crec;
int32_t i;
ly_bool first_matched = 0;
LY_ERR r, ret = LY_SUCCESS;
@@ -863,7 +863,7 @@
}
LY_ERR
-lyht_remove(struct hash_table *ht, void *val_p, uint32_t hash)
+lyht_remove(struct ly_ht *ht, void *val_p, uint32_t hash)
{
return lyht_remove_with_resize_cb(ht, val_p, hash, NULL);
}
diff --git a/src/hash_table.h b/src/hash_table.h
index 6b32672..bec7c86 100644
--- a/src/hash_table.h
+++ b/src/hash_table.h
@@ -70,7 +70,7 @@
/**
* @brief Generic hash table record.
*/
-struct ht_rec {
+struct ly_ht_rec {
uint32_t hash; /* hash of the value */
int32_t hits; /* collision/overflow value count - 1 (a filled entry has 1 hit,
* special value -1 means a deleted record) */
@@ -85,7 +85,7 @@
* Removal is lazy (removed records are only marked), but
* if possible, they are fully emptied.
*/
-struct hash_table {
+struct ly_ht {
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 */
uint32_t invalid; /* number of invalid records (deleted) */
@@ -98,7 +98,7 @@
unsigned char *recs; /* pointer to the hash table itself (array of struct ht_rec) */
};
-struct dict_rec {
+struct ly_dict_rec {
char *value;
uint32_t refcount;
};
@@ -106,8 +106,8 @@
/**
* dictionary to store repeating strings
*/
-struct dict_table {
- struct hash_table *hash_tab;
+struct ly_dict {
+ struct ly_ht *hash_tab;
pthread_mutex_t lock;
};
@@ -116,14 +116,14 @@
*
* @param[in] dict Dictionary table to initiate
*/
-void lydict_init(struct dict_table *dict);
+void lydict_init(struct ly_dict *dict);
/**
* @brief Cleanup the dictionary content
*
* @param[in] dict Dictionary table to cleanup
*/
-void lydict_clean(struct dict_table *dict);
+void lydict_clean(struct ly_dict *dict);
/**
* @brief Create new hash table.
@@ -135,7 +135,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, lyht_value_equal_cb val_equal, void *cb_data, uint16_t resize);
+struct ly_ht *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.
@@ -144,7 +144,7 @@
* @param[in] new_val_equal New callback for checking value equivalence.
* @return Previous callback for checking value equivalence.
*/
-lyht_value_equal_cb lyht_set_cb(struct hash_table *ht, lyht_value_equal_cb new_val_equal);
+lyht_value_equal_cb lyht_set_cb(struct ly_ht *ht, lyht_value_equal_cb new_val_equal);
/**
* @brief Set hash table value equal callback user data.
@@ -153,7 +153,7 @@
* @param[in] new_cb_data New data for values callback.
* @return Previous data for values callback.
*/
-void *lyht_set_cb_data(struct hash_table *ht, void *new_cb_data);
+void *lyht_set_cb_data(struct ly_ht *ht, void *new_cb_data);
/**
* @brief Make a duplicate of an existing hash table.
@@ -161,7 +161,7 @@
* @param[in] orig Original hash table to duplicate.
* @return Duplicated hash table @p orig, NULL on error.
*/
-struct hash_table *lyht_dup(const struct hash_table *orig);
+struct ly_ht *lyht_dup(const struct ly_ht *orig);
/**
* @brief Free a hash table.
@@ -169,7 +169,7 @@
* @param[in] ht Hash table to be freed.
* @param[in] val_free Optional callback for freeing allthe stored values, @p val_p is a pointer to a stored value.
*/
-void lyht_free(struct hash_table *ht, void (*val_free)(void *val_p));
+void lyht_free(struct ly_ht *ht, void (*val_free)(void *val_p));
/**
* @brief Find a value in a hash table.
@@ -181,7 +181,7 @@
* @return LY_SUCCESS if value was found,
* @return LY_ENOTFOUND if not found.
*/
-LY_ERR lyht_find(struct hash_table *ht, void *val_p, uint32_t hash, void **match_p);
+LY_ERR lyht_find(struct ly_ht *ht, void *val_p, uint32_t hash, void **match_p);
/**
* @brief Find another equal value in the hash table.
@@ -193,7 +193,7 @@
* @return LY_SUCCESS if value was found,
* @return LY_ENOTFOUND if not found.
*/
-LY_ERR lyht_find_next(struct hash_table *ht, void *val_p, uint32_t hash, void **match_p);
+LY_ERR lyht_find_next(struct ly_ht *ht, void *val_p, uint32_t hash, void **match_p);
/**
* @brief Find another equal value in the hash table. Same functionality as ::lyht_find_next()
@@ -207,7 +207,7 @@
* @return LY_SUCCESS if value was found,
* @return LY_ENOTFOUND if not found.
*/
-LY_ERR lyht_find_next_with_collision_cb(struct hash_table *ht, void *val_p, uint32_t hash,
+LY_ERR lyht_find_next_with_collision_cb(struct ly_ht *ht, void *val_p, uint32_t hash,
lyht_value_equal_cb collision_val_equal, void **match_p);
/**
@@ -222,7 +222,7 @@
* @return LY_EEXIST in case the value is already present.
* @return LY_EMEM in case of memory allocation failure.
*/
-LY_ERR lyht_insert(struct hash_table *ht, void *val_p, uint32_t hash, void **match_p);
+LY_ERR lyht_insert(struct ly_ht *ht, void *val_p, uint32_t hash, void **match_p);
/**
* @brief Insert a value into hash table. Same functionality as ::lyht_insert()
@@ -239,7 +239,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, lyht_value_equal_cb resize_val_equal,
+LY_ERR lyht_insert_with_resize_cb(struct ly_ht *ht, void *val_p, uint32_t hash, lyht_value_equal_cb resize_val_equal,
void **match_p);
/**
@@ -252,7 +252,7 @@
* @return LY_SUCCESS on success,
* @return LY_ENOTFOUND if value was not found.
*/
-LY_ERR lyht_remove(struct hash_table *ht, void *val_p, uint32_t hash);
+LY_ERR lyht_remove(struct ly_ht *ht, void *val_p, uint32_t hash);
/**
* @brief Remove a value from a hash table. Same functionality as ::lyht_remove()
@@ -267,7 +267,7 @@
* @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, lyht_value_equal_cb resize_val_equal);
+LY_ERR lyht_remove_with_resize_cb(struct ly_ht *ht, void *val_p, uint32_t hash, lyht_value_equal_cb resize_val_equal);
/**
* @brief Get suitable size of a hash table for a fixed number of items.
diff --git a/src/lyb.h b/src/lyb.h
index b123ee5..70de5b7 100644
--- a/src/lyb.h
+++ b/src/lyb.h
@@ -95,7 +95,7 @@
/* LYB printer only */
struct lyd_lyb_sib_ht {
struct lysc_node *first_sibling;
- struct hash_table *ht;
+ struct ly_ht *ht;
} *sib_hts;
};
diff --git a/src/printer_lyb.c b/src/printer_lyb.c
index ff64a81..b99ec64 100644
--- a/src/printer_lyb.c
+++ b/src/printer_lyb.c
@@ -81,7 +81,7 @@
* @return LY_EEXIST when the whole hash sequence sollides.
*/
static LY_ERR
-lyb_hash_sequence_check(struct hash_table *ht, struct lysc_node *sibling, LYB_HASH ht_col_id, LYB_HASH compare_col_id)
+lyb_hash_sequence_check(struct ly_ht *ht, struct lysc_node *sibling, LYB_HASH ht_col_id, LYB_HASH compare_col_id)
{
struct lysc_node **col_node;
@@ -123,9 +123,9 @@
* @return LY_ERR value.
*/
static LY_ERR
-lyb_hash_siblings(struct lysc_node *sibling, struct hash_table **ht_p)
+lyb_hash_siblings(struct lysc_node *sibling, struct ly_ht **ht_p)
{
- struct hash_table *ht;
+ struct ly_ht *ht;
const struct lysc_node *parent;
const struct lys_module *mod;
LYB_HASH i;
@@ -205,7 +205,7 @@
* @return LY_ERR value.
*/
static LY_ERR
-lyb_hash_find(struct hash_table *ht, struct lysc_node *node, LYB_HASH *hash_p)
+lyb_hash_find(struct ly_ht *ht, struct lysc_node *node, LYB_HASH *hash_p)
{
LYB_HASH hash;
uint32_t i;
@@ -856,7 +856,7 @@
* @return LY_ERR value.
*/
static LY_ERR
-lyb_print_schema_hash(struct ly_out *out, struct lysc_node *schema, struct hash_table **sibling_ht, struct lylyb_ctx *lybctx)
+lyb_print_schema_hash(struct ly_out *out, struct lysc_node *schema, struct ly_ht **sibling_ht, struct lylyb_ctx *lybctx)
{
LY_ARRAY_COUNT_TYPE u;
uint32_t i;
@@ -1205,7 +1205,7 @@
* @return LY_ERR value.
*/
static LY_ERR
-lyb_print_node(struct ly_out *out, const struct lyd_node **printed_node, struct hash_table **sibling_ht,
+lyb_print_node(struct ly_out *out, const struct lyd_node **printed_node, struct ly_ht **sibling_ht,
struct lyd_lyb_ctx *lybctx)
{
const struct lyd_node *node = *printed_node;
@@ -1256,7 +1256,7 @@
static LY_ERR
lyb_print_siblings(struct ly_out *out, const struct lyd_node *node, struct lyd_lyb_ctx *lybctx)
{
- struct hash_table *sibling_ht = NULL;
+ struct ly_ht *sibling_ht = NULL;
const struct lys_module *prev_mod = NULL;
LY_CHECK_RET(lyb_write_start_siblings(out, lybctx->lybctx));
diff --git a/src/tree_data.c b/src/tree_data.c
index 21a0aba..2d651b5 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -2023,13 +2023,13 @@
*/
static LY_ERR
lyd_merge_sibling_r(struct lyd_node **first_trg, struct lyd_node *parent_trg, const struct lyd_node **sibling_src_p,
- lyd_merge_cb merge_cb, void *cb_data, uint16_t options, struct hash_table **dup_inst)
+ lyd_merge_cb merge_cb, void *cb_data, uint16_t options, struct ly_ht **dup_inst)
{
const struct lyd_node *child_src, *tmp, *sibling_src;
struct lyd_node *match_trg, *dup_src, *elem;
struct lyd_node_opaq *opaq_trg, *opaq_src;
struct lysc_type *type;
- struct hash_table *child_dup_inst = NULL;
+ struct ly_ht *child_dup_inst = NULL;
LY_ERR ret;
ly_bool first_inst = 0;
@@ -2151,7 +2151,7 @@
lyd_merge_cb merge_cb, void *cb_data, uint16_t options, ly_bool nosiblings)
{
const struct lyd_node *sibling_src, *tmp;
- struct hash_table *dup_inst = NULL;
+ struct ly_ht *dup_inst = NULL;
ly_bool first;
LY_ERR ret = LY_SUCCESS;
diff --git a/src/tree_data.h b/src/tree_data.h
index 8307db3..9d6bb5b 100644
--- a/src/tree_data.h
+++ b/src/tree_data.h
@@ -822,7 +822,7 @@
}; /**< common part corresponding to ::lyd_node */
struct lyd_node *child; /**< pointer to the first child node. */
- struct hash_table *children_ht; /**< hash table with all the direct children (except keys for a list, lists without keys) */
+ struct ly_ht *children_ht; /**< hash table with all the direct children (except keys for a list, lists without keys) */
#define LYD_HT_MIN_ITEMS 4 /**< minimal number of children to create ::lyd_node_inner.children_ht hash table. */
};
diff --git a/src/tree_data_common.c b/src/tree_data_common.c
index 51d971e..1e1b9c0 100644
--- a/src/tree_data_common.c
+++ b/src/tree_data_common.c
@@ -74,7 +74,7 @@
* @return Instance cache entry.
*/
static struct lyd_dup_inst *
-lyd_dup_inst_get(const struct lyd_node *first_inst, struct hash_table **dup_inst_ht)
+lyd_dup_inst_get(const struct lyd_node *first_inst, struct ly_ht **dup_inst_ht)
{
struct lyd_dup_inst **item_p, *item;
@@ -102,7 +102,7 @@
}
LY_ERR
-lyd_dup_inst_next(struct lyd_node **inst, const struct lyd_node *siblings, struct hash_table **dup_inst_ht)
+lyd_dup_inst_next(struct lyd_node **inst, const struct lyd_node *siblings, struct ly_ht **dup_inst_ht)
{
struct lyd_dup_inst *dup_inst;
@@ -151,7 +151,7 @@
}
void
-lyd_dup_inst_free(struct hash_table *dup_inst_ht)
+lyd_dup_inst_free(struct ly_ht *dup_inst_ht)
{
lyht_free(dup_inst_ht, lyht_dup_inst_ht_free_cb);
}
diff --git a/src/tree_data_hash.c b/src/tree_data_hash.c
index 52f99a8..79e0031 100644
--- a/src/tree_data_hash.c
+++ b/src/tree_data_hash.c
@@ -121,7 +121,7 @@
* @return LY_ERR value.
*/
static LY_ERR
-lyd_insert_hash_add(struct hash_table *ht, struct lyd_node *node, ly_bool empty_ht)
+lyd_insert_hash_add(struct ly_ht *ht, struct lyd_node *node, ly_bool empty_ht)
{
uint32_t hash;
diff --git a/src/tree_data_internal.h b/src/tree_data_internal.h
index 40bc562..e87723b 100644
--- a/src/tree_data_internal.h
+++ b/src/tree_data_internal.h
@@ -50,15 +50,14 @@
* @param[in] dup_inst_ht Duplicate instance cache hash table.
* @return LY_ERR value.
*/
-LY_ERR lyd_dup_inst_next(struct lyd_node **inst, const struct lyd_node *siblings,
- struct hash_table **dup_inst_ht);
+LY_ERR lyd_dup_inst_next(struct lyd_node **inst, const struct lyd_node *siblings, struct ly_ht **dup_inst_ht);
/**
* @brief Free duplicate instance cache.
*
* @param[in] dup_inst Duplicate instance cache hash table to free.
*/
-void lyd_dup_inst_free(struct hash_table *dup_inst_ht);
+void lyd_dup_inst_free(struct ly_ht *dup_inst_ht);
/**
* @brief Just like ::lys_getnext() but iterates over all data instances of the schema nodes.
diff --git a/src/tree_schema_common.c b/src/tree_schema_common.c
index dcd05a4..95a6c1e 100644
--- a/src/tree_schema_common.c
+++ b/src/tree_schema_common.c
@@ -350,14 +350,13 @@
* @param[in,out] ctx Context to log the error.
* @param[in,out] ht Hash table with top-level names.
* @param[in] name Inserted top-level identifier.
- * @param[in] statement The name of the statement type from which
- * @p name originated (eg typedef, feature, ...).
+ * @param[in] statement The name of the statement type from which @p name originated (eg typedef, feature, ...).
* @param[in] err_detail Optional error specification.
* @return LY_ERR, but LY_EEXIST is mapped to LY_EVALID.
*/
static LY_ERR
-lysp_check_dup_ht_insert(struct lysp_ctx *ctx, struct hash_table *ht,
- const char *name, const char *statement, const char *err_detail)
+lysp_check_dup_ht_insert(struct lysp_ctx *ctx, struct ly_ht *ht, const char *name, const char *statement,
+ const char *err_detail)
{
LY_ERR ret;
uint32_t hash;
@@ -388,7 +387,7 @@
*/
static LY_ERR
lysp_check_dup_typedef(struct lysp_ctx *ctx, struct lysp_node *node, const struct lysp_tpdf *tpdf,
- struct hash_table *tpdfs_global)
+ struct ly_ht *tpdfs_global)
{
struct lysp_node *parent;
uint32_t hash;
@@ -469,7 +468,7 @@
LY_ERR
lysp_check_dup_typedefs(struct lysp_ctx *ctx, struct lysp_module *mod)
{
- struct hash_table *ids_global;
+ struct ly_ht *ids_global;
const struct lysp_tpdf *typedefs;
LY_ARRAY_COUNT_TYPE u, v;
uint32_t i;
@@ -528,7 +527,7 @@
*/
static LY_ERR
lysp_check_dup_grouping(struct lysp_ctx *ctx, struct lysp_node *node, const struct lysp_node_grp *grp,
- struct hash_table *grps_global)
+ struct ly_ht *grps_global)
{
struct lysp_node *parent;
uint32_t hash;
@@ -584,7 +583,7 @@
LY_ERR
lysp_check_dup_groupings(struct lysp_ctx *ctx, struct lysp_module *mod)
{
- struct hash_table *ids_global;
+ struct ly_ht *ids_global;
const struct lysp_node_grp *groupings, *grp_iter;
LY_ARRAY_COUNT_TYPE u;
uint32_t i;
@@ -626,7 +625,7 @@
lysp_check_dup_features(struct lysp_ctx *ctx, struct lysp_module *mod)
{
LY_ARRAY_COUNT_TYPE u;
- struct hash_table *ht;
+ struct ly_ht *ht;
struct lysp_feature *f;
LY_ERR ret = LY_SUCCESS;
@@ -658,7 +657,7 @@
lysp_check_dup_identities(struct lysp_ctx *ctx, struct lysp_module *mod)
{
LY_ARRAY_COUNT_TYPE u;
- struct hash_table *ht;
+ struct ly_ht *ht;
struct lysp_ident *i;
LY_ERR ret = LY_SUCCESS;
diff --git a/src/validation.c b/src/validation.c
index 1ffc42d..89ba74a 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -1250,7 +1250,7 @@
ly_bool dyn;
const void *hash_key;
struct lyd_val_uniq_arg arg, *args = NULL;
- struct hash_table **uniqtables = NULL;
+ struct ly_ht **uniqtables = NULL;
struct lyd_value *val;
struct ly_ctx *ctx = snode->module->ctx;
diff --git a/src/xpath.h b/src/xpath.h
index 803de7d..cfa1fe6 100644
--- a/src/xpath.h
+++ b/src/xpath.h
@@ -291,7 +291,7 @@
/* this is valid only for type LYXP_SET_NODE_SET and LYXP_SET_SCNODE_SET */
uint32_t used; /**< Number of nodes in the set. */
uint32_t size; /**< Allocated size for the set. */
- struct hash_table *ht; /**< Hash table for quick determination of whether a node is in the set. */
+ struct ly_ht *ht; /**< Hash table for quick determination of whether a node is in the set. */
/* XPath context information, this is valid only for type LYXP_SET_NODE_SET */
uint32_t ctx_pos; /**< Position of the current examined node in the set. */
diff --git a/tests/utests/basic/test_hash_table.c b/tests/utests/basic/test_hash_table.c
index d823051..efb5554 100644
--- a/tests/utests/basic/test_hash_table.c
+++ b/tests/utests/basic/test_hash_table.c
@@ -19,7 +19,7 @@
#include "common.h"
#include "hash_table.h"
-struct ht_rec *lyht_get_rec(unsigned char *recs, uint16_t rec_size, uint32_t idx);
+struct ly_ht_rec *lyht_get_rec(unsigned char *recs, uint16_t rec_size, uint32_t idx);
static void
test_invalid_arguments(void **state)
@@ -83,7 +83,7 @@
test_ht_basic(void **state)
{
uint32_t i;
- struct hash_table *ht;
+ struct ly_ht *ht;
assert_non_null(ht = lyht_new(8, sizeof(int), ht_equal_clb, NULL, 0));
@@ -103,8 +103,8 @@
test_ht_resize(void **state)
{
uint32_t i;
- struct ht_rec *rec;
- struct hash_table *ht;
+ struct ly_ht_rec *rec;
+ struct ly_ht *ht;
assert_non_null(ht = lyht_new(8, sizeof(int), ht_equal_clb, NULL, 1));
assert_int_equal(8, ht->size);
@@ -162,8 +162,8 @@
#define GET_REC_INT(rec) (*((uint32_t *)&(rec)->val))
uint32_t i;
- struct ht_rec *rec;
- struct hash_table *ht;
+ struct ly_ht_rec *rec;
+ struct ly_ht *ht;
assert_non_null(ht = lyht_new(8, sizeof(int), ht_equal_clb, NULL, 1));