[core] fix incorrect hash algorithm impl

fix incorrect implementation of djb hash algorithm
This commit is contained in:
Glenn Strauss 2018-03-11 12:18:41 -04:00
parent 5a6e4df85c
commit 758d24142b
1 changed files with 2 additions and 3 deletions

View File

@ -88,9 +88,8 @@ typedef struct stat_cache {
/* the famous DJB hash function for strings */
static uint32_t hashme(buffer *str) {
uint32_t hash = 5381;
const char *s;
for (s = str->ptr; *s; s++) {
hash = ((hash << 5) + hash) + *s;
for (const unsigned char *s = (unsigned char *)str->ptr; *s; ++s) {
hash = ((hash << 5) + hash) ^ *s;
}
hash &= ~(((uint32_t)1) << 31); /* strip the highest bit */