summaryrefslogtreecommitdiff
path: root/lib/tdb/common/open.c
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2010-09-24 15:34:06 +0930
committerRusty Russell <rusty@rustcorp.com.au>2010-09-27 10:48:28 +0930
commit3258cf3f11bf7c68a2e69e1808c4551cc899725a (patch)
tree4936334d88f8e159c0412f8f3370f3ab07c0817d /lib/tdb/common/open.c
parent7afa7b8a848a6afdb586768168c95b566b7b912f (diff)
downloadsamba-3258cf3f11bf7c68a2e69e1808c4551cc899725a.tar.gz
samba-3258cf3f11bf7c68a2e69e1808c4551cc899725a.tar.bz2
samba-3258cf3f11bf7c68a2e69e1808c4551cc899725a.zip
tdb: add Bob Jenkins lookup3 hash as helper hash.
This is a better hash than the default: shipping it with tdb makes it easy for callers to use it as the hash by passing it to tdb_open_ex(). This version taken from CCAN and modified, which took it from http://www.burtleburtle.net/bob/c/lookup3.c. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'lib/tdb/common/open.c')
-rw-r--r--lib/tdb/common/open.c16
1 files changed, 1 insertions, 15 deletions
diff --git a/lib/tdb/common/open.c b/lib/tdb/common/open.c
index a964994509..f0e2dfc7e1 100644
--- a/lib/tdb/common/open.c
+++ b/lib/tdb/common/open.c
@@ -30,20 +30,6 @@
/* all contexts, to ensure no double-opens (fcntl locks don't nest!) */
static struct tdb_context *tdbs = NULL;
-
-/* This is based on the hash algorithm from gdbm */
-static unsigned int default_tdb_hash(TDB_DATA *key)
-{
- uint32_t value; /* Used to compute the hash value. */
- uint32_t i; /* Used to cycle through random values. */
-
- /* 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)));
-
- return (1103515243 * value + 12345);
-}
-
/* We use two hashes to double-check they're using the right hash function. */
void tdb_header_hash(struct tdb_context *tdb,
uint32_t *magic1_hash, uint32_t *magic2_hash)
@@ -191,7 +177,7 @@ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
tdb->hash_fn = hash_fn;
hash_alg = "user defined";
} else {
- tdb->hash_fn = default_tdb_hash;
+ tdb->hash_fn = tdb_old_hash;
hash_alg = "default";
}