siphash24: unify API

Make the API of the new helpers more similar to the old wrapper.

In particular we now return the hash as a byte string to avoid
any endianness problems.
This commit is contained in:
Tom Gundersen
2015-10-06 17:47:00 +02:00
parent 8c60d978bd
commit 0cb3c28688
7 changed files with 37 additions and 38 deletions
+5 -2
View File
@@ -372,12 +372,15 @@ static uint8_t *hash_key(HashmapBase *h) {
static unsigned base_bucket_hash(HashmapBase *h, const void *p) {
struct siphash state;
uint64_t hash;
siphash_init(&state, hash_key(h));
siphash24_init(&state, hash_key(h));
h->hash_ops->hash(p, &state);
return (unsigned) (siphash24_finalize(&state) % n_buckets(h));
siphash24_finalize((uint8_t*)&hash, &state);
return (unsigned) (hash % n_buckets(h));
}
#define bucket_hash(h, p) base_bucket_hash(HASHMAP_BASE(h), p)