diff options
author | Stef Walter <stefw@gnome.org> | 2013-03-20 09:33:04 +0100 |
---|---|---|
committer | Stef Walter <stefw@gnome.org> | 2013-03-20 10:54:00 +0100 |
commit | f45942a4fc3e1c5219e9b5201b82203337ee7280 (patch) | |
tree | f83313676d1c8de9dbc48d161e16c13264bc8049 /common/dict.c | |
parent | 1dc227b4fce16fcc721276925492f4ba4db00b4f (diff) | |
download | p11-kit-f45942a4fc3e1c5219e9b5201b82203337ee7280.tar.gz |
hash: Add the murmur2 hash and start using it
Add implementation of the murmur2 hash function, and start using
it for our dictionaries. Our implementation is incremental
like our other hash functions.
Also remove p11_oid_hash() which wasn't being used.
In addition fix several tests whose success was based on the
way that the dictionary hashed. This was a hidden testing bug.
Diffstat (limited to 'common/dict.c')
-rw-r--r-- | common/dict.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/common/dict.c b/common/dict.c index df8c7ac..409e3a4 100644 --- a/common/dict.c +++ b/common/dict.c @@ -35,10 +35,12 @@ #include "debug.h" #include "dict.h" +#include "hash.h" #include <sys/types.h> #include <assert.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> @@ -326,13 +328,8 @@ p11_dict_size (p11_dict *dict) unsigned int p11_dict_str_hash (const void *string) { - const char *p = string; - unsigned int hash = *p; - - if (hash) - for (p += 1; *p != '\0'; p++) - hash = (hash << 5) - hash + *p; - + uint32_t hash; + p11_hash_murmur2 (&hash, string, strlen (string), NULL); return hash; } |