X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libhashkit%2Fhsieh.c;h=cb5af8aec74524540fd97afb2b1bac0ffd797c07;hb=16c2fe9cc04a3f15fe56d3be2f3be19a1d731fb2;hp=c688add6c6d914bac9c0ca11a56fc1f5e194df61;hpb=ec7ac8f2c7a6ccbb2f52f83ff275275177e0907b;p=m6w6%2Flibmemcached diff --git a/libhashkit/hsieh.c b/libhashkit/hsieh.c index c688add6..cb5af8ae 100644 --- a/libhashkit/hsieh.c +++ b/libhashkit/hsieh.c @@ -23,7 +23,7 @@ uint32_t hashkit_hsieh(const char *key, size_t key_length, void *context __attri int rem; if (key_length <= 0 || key == NULL) - return 0; + return EXIT_SUCCESS; rem = key_length & 3; key_length >>= 2; @@ -43,16 +43,18 @@ uint32_t hashkit_hsieh(const char *key, size_t key_length, void *context __attri { case 3: hash += get16bits (key); hash ^= hash << 16; - hash ^= key[sizeof (uint16_t)] << 18; + hash ^= (uint32_t)key[sizeof (uint16_t)] << 18; hash += hash >> 11; break; case 2: hash += get16bits (key); hash ^= hash << 11; hash += hash >> 17; break; - case 1: hash += *key; + case 1: hash += (unsigned char)(*key); hash ^= hash << 10; hash += hash >> 1; + default: + break; } /* Force "avalanching" of final 127 bits */