From b6f01820cab6fe2d6e830259a0dcb6efeb16b06c Mon Sep 17 00:00:00 2001 From: Robert Pengelly Date: Fri, 20 Dec 2024 15:53:48 +0000 Subject: [PATCH] Updated hashing function --- hashtab.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hashtab.c b/hashtab.c index b6863a5..9ddaf7e 100644 --- a/hashtab.c +++ b/hashtab.c @@ -98,10 +98,12 @@ static struct hashtab_entry *find_entry (struct hashtab_entry *entries, unsigned static unsigned int hash_string (const void *p, unsigned int length) { unsigned char *str = (unsigned char *) p; - unsigned int i, result = 0; + unsigned int i; + + unsigned int result = 0; for (i = 0; i < length; i++) { - result = (((unsigned int) str[i]) << 12) + (result >> 6) + result + (result >> 3) + (((unsigned int) str[i]) << 8) - result; + result = (((unsigned short) str[i]) << 4) + (result >> 9) + result + (result >> 3) + (((unsigned short) str[i]) << 2) - (result << 24); } return result; -- 2.34.1