projects
/
awesomized
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
Updated for custom hash functions/setting functions.
[awesomized/libmemcached]
/
libmemcached
/
murmur_hash.c
diff --git
a/libmemcached/murmur_hash.c
b/libmemcached/murmur_hash.c
index c9e60f5bf6e32ec12e2b4ada421043361833c857..f1c3267c53844ee903889d913fba3e0f8b95797d 100644
(file)
--- a/
libmemcached/murmur_hash.c
+++ b/
libmemcached/murmur_hash.c
@@
-25,13
+25,13
@@
uint32_t murmur_hash(const char *key, size_t length)
*/
const unsigned int m= 0x5bd1e995;
*/
const unsigned int m= 0x5bd1e995;
- const u
nsigned int seed= (0xdeadbeef *
length);
+ const u
int32_t seed= (0xdeadbeef * (uint32_t)
length);
const int r= 24;
// Initialize the hash to a 'random' value
const int r= 24;
// Initialize the hash to a 'random' value
- u
nsigned int h= seed ^
length;
+ u
int32_t h= seed ^ (uint32_t)
length;
// Mix 4 bytes at a time into the hash
// Mix 4 bytes at a time into the hash
@@
-56,10
+56,11
@@
uint32_t murmur_hash(const char *key, size_t length)
switch(length)
{
switch(length)
{
- case 3: h ^=
data[2]
<< 16;
- case 2: h ^=
data[1]
<< 8;
+ case 3: h ^=
((uint32_t)data[2])
<< 16;
+ case 2: h ^=
((uint32_t)data[1])
<< 8;
case 1: h ^= data[0];
h *= m;
case 1: h ^= data[0];
h *= m;
+ default: break;
};
/*
};
/*
@@
-71,5
+72,5
@@
uint32_t murmur_hash(const char *key, size_t length)
h *= m;
h ^= h >> 15;
h *= m;
h ^= h >> 15;
- return h;
+ return
(uint32_t)
h;
}
}