Fix
This commit is contained in:
parent
355f96d5e7
commit
f34dfcdccd
1 changed files with 5 additions and 6 deletions
11
djb2.c
11
djb2.c
|
@ -1,15 +1,14 @@
|
|||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
* Simple hash function djb2, as in Daniel J. Berenstein.
|
||||
*/
|
||||
|
||||
unsigned long djb2(const char *str) {
|
||||
unsigned long h = 5381;
|
||||
int c;
|
||||
|
||||
while ((c = *str++)) {
|
||||
h = ((h << 5) + h) + c;
|
||||
|
||||
// Essentially equal to:
|
||||
// h = h * 33 + c;
|
||||
}
|
||||
while ((c = *str++)) h = ((h << 5) + h) + c; // h = h * 33 + c;
|
||||
|
||||
return h;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue