diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-08-24 17:35:02 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-08-24 17:35:02 +0100 |
commit | a1be94b4c4b59de216e0b8b721a951b2325f7215 (patch) | |
tree | 6bb00558dd03918b500468e7385d716e83499265 /src/libutil/uthash_strcase.h | |
parent | 71f5454dc80cb2cc90363e219d85533b0e7a7895 (diff) | |
download | rspamd-a1be94b4c4b59de216e0b8b721a951b2325f7215.tar.gz rspamd-a1be94b4c4b59de216e0b8b721a951b2325f7215.zip |
Rework lists and hashes.
Diffstat (limited to 'src/libutil/uthash_strcase.h')
-rw-r--r-- | src/libutil/uthash_strcase.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libutil/uthash_strcase.h b/src/libutil/uthash_strcase.h index 1b4024cc6..4e28f3110 100644 --- a/src/libutil/uthash_strcase.h +++ b/src/libutil/uthash_strcase.h @@ -25,13 +25,28 @@ #include "xxhash.h" + /* Utils for uthash tuning */ +#ifndef HASH_CASELESS #define HASH_FUNCTION(key,keylen,num_bkts,hashv,bkt) do {\ hashv = XXH32(key, keylen, 0); \ bkt = (hashv) & (num_bkts-1); \ } while (0) +#define HASH_KEYCMP(a,b,len) memcmp(a,b,len) +#else +#define HASH_FUNCTION(key,keylen,num_bkts,hashv,bkt) do {\ + void *xxh = XXH32_init(0xdead); \ + unsigned char *p = (unsigned char *)key, t; \ + for (unsigned int i = 0; i < keylen; i ++) { \ + t = g_ascii_tolower(p[i]); \ + XXH32_update(xxh, &t, 1); \ + } \ + hashv = XXH32_digest(xxh); \ + bkt = (hashv) & (num_bkts-1); \ +} while (0) #define HASH_KEYCMP(a,b,len) strncasecmp(a,b,len) +#endif #include "uthash.h" |