From: Stefan Metzmacher Date: Fri, 10 Sep 2010 04:40:03 +0000 (+0200) Subject: TODO lib/tdb: use jenkins_hash for non persistent tdbs X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=9f09d9bef7877e553d6d7c56eb04cdade311c5e6;p=metze%2Fsamba%2Fwip.git TODO lib/tdb: use jenkins_hash for non persistent tdbs metze --- diff --git a/lib/tdb/common/open.c b/lib/tdb/common/open.c index ff0fd376017b..97fd5b1cc2f0 100644 --- a/lib/tdb/common/open.c +++ b/lib/tdb/common/open.c @@ -44,6 +44,10 @@ static unsigned int default_tdb_hash(TDB_DATA *key) return (1103515243 * value + 12345); } +static unsigned int jenkins_hash(TDB_DATA *key) +{ + return hash_any(key->dptr, key->dsize, 0); +} /* initialise a new database with a specified hash size */ static int tdb_new_database(struct tdb_context *tdb, int hash_size) @@ -190,8 +194,13 @@ 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; - hash_alg = "default"; + if (tdb_flags & TDB_CLEAR_IF_FIRST) { + tdb->hash_fn = jenkins_hash; + hash_alg = "jenkins"; + } else { + tdb->hash_fn = default_tdb_hash; + hash_alg = "default"; + } } /* cache the page size */