cb3d5218391037f052061bbfc64f2c552fb58277
4 static unsigned int internal_generate_hash(char *key
, size_t key_length
);
6 unsigned int memcached_generate_hash(memcached_st
*ptr
, char *key
, size_t key_length
)
8 unsigned int return_value
;
10 if (ptr
->flags
& MEM_USE_MD5
)
12 unsigned char results
[16];
14 md5_signature((unsigned char*)key
, (unsigned int)key_length
, results
);
16 return_value
= (unsigned int)(( results
[3] << 24 )
17 | ( results
[2] << 16 )
22 return_value
= internal_generate_hash(key
, key_length
);
24 return return_value
% ptr
->number_of_hosts
;
27 static unsigned int internal_generate_hash(char *key
, size_t key_length
)
30 unsigned int value
= 0;
35 value
+= (value
<< 10);
36 value
^= (value
>> 6);
38 value
+= (value
<< 3);
39 value
^= (value
>> 11);
40 value
+= (value
<< 15);
42 return value
== 0 ? 1 : value
;