X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb2%2Ftdb1_hash.c;h=2d5e4961a30b78ecca2da21fb006a1c71a85c253;hp=a8dd065535e3a56b65888a2595928182f13f723c;hb=56023cca5f66a40646a1e807c3d10af6e5913623;hpb=39f55294799c6443c0ad7bef09f1c113cf89d295 diff --git a/ccan/tdb2/tdb1_hash.c b/ccan/tdb2/tdb1_hash.c index a8dd0655..2d5e4961 100644 --- a/ccan/tdb2/tdb1_hash.c +++ b/ccan/tdb2/tdb1_hash.c @@ -25,14 +25,15 @@ #include "tdb1_private.h" /* This is based on the hash algorithm from gdbm */ -unsigned int tdb1_old_hash(TDB1_DATA *key) +uint64_t tdb1_old_hash(const void *key, size_t len, uint64_t seed, void *unused) { uint32_t value; /* Used to compute the hash value. */ uint32_t i; /* Used to cycle through random values. */ + const unsigned char *dptr = key; /* Set the initial value from the key size. */ - for (value = 0x238F13AF * key->dsize, i=0; i < key->dsize; i++) - value = (value + (key->dptr[i] << (i*5 % 24))); + for (value = 0x238F13AF * len, i=0; i < len; i++) + value = (value + (dptr[i] << (i*5 % 24))); return (1103515243 * value + 12345); } @@ -339,7 +340,8 @@ static uint32_t hashlittle( const void *key, size_t length ) return c; } -unsigned int tdb1_jenkins_hash(TDB1_DATA *key) +uint64_t tdb1_incompatible_hash(const void *key, size_t len, uint64_t seed, + void *unused) { - return hashlittle(key->dptr, key->dsize); + return hashlittle(key, len); }