hashtable: fix linked list

This commit is contained in:
Matheus
2023-09-17 01:31:55 -03:00
parent ac0961c9a6
commit 14aca89361
+5
View File
@@ -4,6 +4,7 @@
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include <util.h> #include <util.h>
#include <logging.h>
static scache_t *hashentrycache; static scache_t *hashentrycache;
@@ -44,11 +45,15 @@ int hashtable_set(hashtable_t *table, void *value, void *key, size_t keysize, bo
memcpy(entry->key, key, keysize); memcpy(entry->key, key, keysize);
entry->prev = NULL; entry->prev = NULL;
entry->next = table->entries[tableoffset]; entry->next = table->entries[tableoffset];
if (entry->next)
entry->next->prev = entry;
entry->value = value; entry->value = value;
entry->keysize = keysize; entry->keysize = keysize;
entry->hash = hash; entry->hash = hash;
table->entries[tableoffset] = entry; table->entries[tableoffset] = entry;
++table->entrycount; ++table->entrycount;
return 0; return 0;
} }