summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/cache.c4
-rw-r--r--lib/hashtable.c8
2 files changed, 9 insertions, 3 deletions
diff --git a/lib/cache.c b/lib/cache.c
index 960459d..f0a626c 100644
--- a/lib/cache.c
+++ b/lib/cache.c
@@ -438,7 +438,9 @@ static int __cache_add(struct nl_cache *cache, struct nl_object *obj)
obj->ce_cache = cache;
if (cache->hashtable) {
- ret = nl_hash_table_add(cache->hashtable, obj);
+ ret = _nl_hash_table_add(cache->hashtable, obj,
+ (obj->ce_msgflags & NLM_F_APPEND) ||
+ (obj->ce_flags & NL_OBJ_DUMP));
if (ret < 0) {
obj->ce_cache = NULL;
return ret;
diff --git a/lib/hashtable.c b/lib/hashtable.c
index 7652e6b..f0449b6 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -164,6 +164,11 @@ struct nl_object* nl_hash_table_lookup_mask(nl_hash_table_t *ht,
*/
int nl_hash_table_add(nl_hash_table_t *ht, struct nl_object *obj)
{
+ return _nl_hash_table_add(ht, obj, 0);
+}
+
+int _nl_hash_table_add(nl_hash_table_t *ht, struct nl_object *obj, int append)
+{
nl_hash_node_t *node, *head;
uint32_t key_hash;
@@ -199,8 +204,7 @@ int nl_hash_table_add(nl_hash_table_t *ht, struct nl_object *obj)
node->key_size = sizeof(uint32_t);
nl_init_list_head(&node->list);
- if ((obj->ce_msgflags & NLM_F_APPEND) ||
- (obj->ce_flags & NL_OBJ_DUMP))
+ if (append)
nl_list_add_tail(&node->list, &ht->nodes[key_hash]->list);
else
nl_list_add_head(&node->list, &ht->nodes[key_hash]->list);