Another attempt to ensure that string hashing can't overflow

This commit is contained in:
Eric Fischer
2016-04-28 11:52:16 -07:00
parent 5490f3e15f
commit 40a6b7b37a
+1 -1
View File
@@ -10,7 +10,7 @@
static int hash(const char *s) {
unsigned h = 0;
for (; *s; s++) {
h = (h * 37 + *s) & ULONG_MAX;
h = (h * 37LL + (*s & 0xFF)) & ULONG_MAX;
}
return h & 0xFF;
}