From 3534b428629be185e096be99e3bd5fdfe32d5544 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Thu, 18 Sep 2014 18:55:44 +0000 Subject: initial commit with rc for skalibs-2.0.0.0 --- src/libstddjb/cdb_hash.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/libstddjb/cdb_hash.c (limited to 'src/libstddjb/cdb_hash.c') diff --git a/src/libstddjb/cdb_hash.c b/src/libstddjb/cdb_hash.c new file mode 100644 index 0000000..9eedf54 --- /dev/null +++ b/src/libstddjb/cdb_hash.c @@ -0,0 +1,17 @@ +/* ISC license. */ + +#include +#include + +uint32 cdb_hashadd (uint32 h, unsigned char c) +{ + h += (h << 5) ; + return h ^ c ; +} + +uint32 cdb_hash (char const *buf, unsigned int len) +{ + uint32 h = CDB_HASHSTART ; + while (len--) h = cdb_hashadd(h, *buf++) ; + return h ; +} -- cgit v1.3.1