DTrace support
[awesomized/libmemcached] / lib / memcached_hash.c
1 #include "common.h"
2
3 unsigned int memcached_generate_hash(char *key, size_t key_length)
4 {
5 unsigned int x = key_length;
6 char *ptr = key;
7 unsigned int value = 0;
8
9 while (x--)
10 {
11 value += *ptr++;
12 value += (value << 10);
13 value ^= (value >> 6);
14 }
15 value += (value << 3);
16 value ^= (value >> 11);
17 value += (value << 15);
18
19 return value == 0 ? 1 : value;
20 }