diff options
Diffstat (limited to 'lib/tdb2/hash.c')
-rw-r--r-- | lib/tdb2/hash.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/tdb2/hash.c b/lib/tdb2/hash.c index 1359cfecd6..56c5086e74 100644 --- a/lib/tdb2/hash.c +++ b/lib/tdb2/hash.c @@ -16,8 +16,20 @@ License along with this library; if not, see <http://www.gnu.org/licenses/>. */ #include "private.h" +#include <ccan/hash/hash.h> #include <assert.h> +/* Default hash function. */ +uint64_t tdb_jenkins_hash(const void *key, size_t length, uint64_t seed, + void *unused) +{ + uint64_t ret; + /* hash64_stable assumes lower bits are more important; they are a + * slightly better hash. We use the upper bits first, so swap them. */ + ret = hash64_stable((const unsigned char *)key, length, seed); + return (ret >> 32) | (ret << 32); +} + uint64_t tdb_hash(struct tdb_context *tdb, const void *ptr, size_t len) { return tdb->hash_fn(ptr, len, tdb->hash_seed, tdb->hash_data); |