Merge Jean-Charles
[awesomized/libmemcached] / libhashkit / default.c
1 /* HashKit
2 * Copyright (C) 2009 Brian Aker
3 * All rights reserved.
4 *
5 * Use and distribution licensed under the BSD license. See
6 * the COPYING file in the parent directory for full text.
7 */
8
9 #include "common.h"
10
11 uint32_t hashkit_default(const char *key, size_t key_length)
12 {
13 const char *ptr= key;
14 uint32_t value= 0;
15
16 while (key_length--)
17 {
18 uint32_t val= (uint32_t) *ptr++;
19 value += val;
20 value += (value << 10);
21 value ^= (value >> 6);
22 }
23 value += (value << 3);
24 value ^= (value >> 11);
25 value += (value << 15);
26
27 return value;
28 }