diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2011-09-14 07:41:13 +0930 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2011-09-14 07:41:13 +0930 |
commit | f7e84f8ef86c3323f70e2fa30fd8a49cab1febf9 (patch) | |
tree | 580a9c1302b332602263b7f1192ea5ee61d43521 /lib/tdb2/tdb1_hash.c | |
parent | b4a5c6dcb6c60a32b92772396dadfffa6b721732 (diff) | |
download | samba-f7e84f8ef86c3323f70e2fa30fd8a49cab1febf9.tar.gz samba-f7e84f8ef86c3323f70e2fa30fd8a49cab1febf9.tar.bz2 samba-f7e84f8ef86c3323f70e2fa30fd8a49cab1febf9.zip |
tdb2: Make TDB1 use the same tdb_hash() wrapper as TDB2
This means converting the tdb1 inbuilt hash functions to the
tdb2-style, so they return 64 bit. We truncate to 32 bit everywhere
but in tdb_check() which needs to do so explicitly.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit 3e46dde21261966941469a6c75e1b45cd2d26324)
Diffstat (limited to 'lib/tdb2/tdb1_hash.c')
-rw-r--r-- | lib/tdb2/tdb1_hash.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/tdb2/tdb1_hash.c b/lib/tdb2/tdb1_hash.c index 886577da70..2d5e4961a3 100644 --- a/lib/tdb2/tdb1_hash.c +++ b/lib/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(TDB_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_incompatible_hash(TDB_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); } |