I am using the djb2 algorithm to generate the hash key for a string which is as follows
hash(unsigned char *str) { unsigned long hash = 5381; int c;
You shouldn't do that. Since there is no modulo, integer overflow is the expected behavior for the function (and it was designed with it in mind). Why do you want to change it?