12 #include <netlink-private/netlink.h>
13 #include <netlink/object.h>
14 #include <netlink/hash.h>
15 #include <netlink/hashtable.h>
33 ht = calloc(1,
sizeof (*ht));
37 ht->nodes = calloc(size,
sizeof (*ht->nodes));
60 for(i = 0; i < ht->size; i++) {
87 struct nl_object *obj)
93 node = ht->nodes[key_hash];
123 node = ht->nodes[key_hash];
127 NL_DBG(2,
"Warning: Add to hashtable found duplicate...\n");
133 NL_DBG (5,
"adding cache entry of obj %p in table %p, with hash 0x%x\n",
141 node->key = key_hash;
142 node->key_size =
sizeof(uint32_t);
143 node->next = ht->nodes[key_hash];
144 ht->nodes[key_hash] = node;
167 prev = node = ht->nodes[key_hash];
173 NL_DBG (5,
"deleting cache entry of obj %p in table %p, with"
174 " hash 0x%x\n", obj, ht, key_hash);
176 if (node == ht->nodes[key_hash])
177 ht->nodes[key_hash] = node->next;
179 prev->next = node->next;
189 return -NLE_OBJ_NOTFOUND;
192 uint32_t nl_hash(
void *k,
size_t length, uint32_t initval)
194 return(__nl_hash(k, length, initval));