Suggested bug fix in st__strhash().

This commit is contained in:
Alan Mishchenko 2016-04-30 10:40:54 -07:00
parent 59f3389c9b
commit 2de8f04c0d
1 changed files with 6 additions and 7 deletions

View File

@ -448,14 +448,13 @@ int
int
st__strhash(const char *string, int modulus)
{
int val = 0;
int c;
while ((c = *string++) != '\0') {
val = val*997 + c;
unsigned char * ustring = (unsigned char *)string;
unsigned c, val = 0;
assert( modulus > 0 );
while ((c = *ustring++) != '\0') {
val = val*997 + c;
}
return ((val < 0) ? -val : val)%modulus;
return (int)(val%modulus);
}
int