diff options
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -0,0 +1,15 @@ +#include "hash.h" + +/* + * http://www.cse.yorku.ca/~oz/hash.html + * djb2 from above url. + */ +unsigned long hash(char* str) { + unsigned long hash = 5381; + int c; + + while ( (c = *str++) ) + hash = ((hash << 5) + hash) + c; + + return hash; +} |