1 2 3 4 5 6 7 8 9 10 11 12 13 14 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; }