aboutsummaryrefslogtreecommitdiff
path: root/hash.c
blob: 47775b591d2f5721871092a71fc9f37700b8d128 (plain)
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;
}