]> mj.ucw.cz Git - libucw.git/commitdiff
Added block hash function.
authorMartin Mares <mj@ucw.cz>
Sun, 26 May 2002 16:08:47 +0000 (16:08 +0000)
committerMartin Mares <mj@ucw.cz>
Sun, 26 May 2002 16:08:47 +0000 (16:08 +0000)
lib/Makefile
lib/hash-block.c [new file with mode: 0644]
lib/hashfunc.h

index 70853050d4b3a315e106f5421d79f78950b780ca..f732d0e077b45c42bbdb651c8edb81b7c1b834a8 100644 (file)
@@ -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 (file)
index 0000000..82bf4e2
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ *     Sherlock Library -- Block Hash Function
+ *
+ *     (c) 2002 Martin Mares <mj@ucw.cz>
+ */
+
+#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;
+}
index 126b8f243a897967f6bea97bc60f824f44d3e47d..8e49e4ca3f699d36ede9afb394a59af44a5695fe 100644 (file)
@@ -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