From d07940af96825cc49fe729f281348366a49a076a Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 26 May 2002 16:08:47 +0000 Subject: [PATCH] Added block hash function. --- lib/Makefile | 2 +- lib/hash-block.c | 17 +++++++++++++++++ lib/hashfunc.h | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 lib/hash-block.c diff --git a/lib/Makefile b/lib/Makefile index 70853050..f732d0e0 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -8,7 +8,7 @@ SHLIB_OBJS=alloc.o alloc_str.o ctmatch.o db.o fastbuf.o fb-file.o fb-mem.o lists prime.o random.o realloc.o regex.o timer.o url.o wildmatch.o \ wordsplit.o str_ctype.o str_upper.o bucket.o conf.o object.o sorter.o \ finger.o proctitle.o ipaccess.o profile.o bitsig.o randomkey.o \ - hash-string.o hash-istring.o custom.o base224.o str_hash.o fb-temp.o + hash-string.o hash-istring.o hash-block.o custom.o base224.o str_hash.o fb-temp.o obj/lib/libsh.a: $(addprefix obj/lib/,$(SHLIB_OBJS)) diff --git a/lib/hash-block.c b/lib/hash-block.c new file mode 100644 index 00000000..82bf4e2d --- /dev/null +++ b/lib/hash-block.c @@ -0,0 +1,17 @@ +/* + * Sherlock Library -- Block Hash Function + * + * (c) 2002 Martin Mares + */ + +#include "lib/lib.h" +#include "lib/hashfunc.h" + +uns +hash_block(byte *k, uns len) +{ + uns h = len; + while (len--) + h = h*37 + *k++; + return h; +} diff --git a/lib/hashfunc.h b/lib/hashfunc.h index 126b8f24..8e49e4ca 100644 --- a/lib/hashfunc.h +++ b/lib/hashfunc.h @@ -10,5 +10,6 @@ uns hash_string(byte *x); uns hash_string_nocase(byte *x); static inline uns hash_int(uns x) { return 6442450967*x; } +uns hash_block(byte *x, uns len); #endif -- 2.39.2