save works

This commit is contained in:
Rongsong Shen 2025-12-18 14:55:58 +08:00
parent d0174f2f30
commit 4db6b039c5
8 changed files with 140 additions and 34 deletions

View file

@ -6,7 +6,7 @@
#include "utils.h"
#define HASH_KEY_HASH(t, key) \
(((t)->fn.hash != NULL) ? ((t)->fn.hash)(key) : (unsigned long)key)
(((t)->fn.hash != NULL) ? ((t)->fn.hash)(key) : hash64((uint64_t)key))
#define HASH_KEY_CMP(t, k1, k2) \
(((t)->fn.cmp != NULL) ? ((t)->fn.cmp)((k1), (k2)) : ((k1) != (k2)))
@ -21,21 +21,9 @@
} \
} while (0)
static unsigned int hash_code(const char* key)
{
unsigned int hc = 5381;
int c;
while ((c = *key++)) {
hc = ((hc << 5) + hc) + c;
}
return hc;
}
static unsigned int string_hash(void* data)
{
return hash_code((const char*)data);
return hash_string((const char*)data);
}
static int string_cmp(void* d1, void* d2)