X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libhashkit%2Fjenkins.c;h=53e35a8299e9d1d54687dae0b8e4a5d45b80e8bc;hb=16c2fe9cc04a3f15fe56d3be2f3be19a1d731fb2;hp=29d9454e3b229ed0ea872e9d92ef6340ff804aa3;hpb=c67da677fe0944d3d2d3ff46e65fc3bc775404ae;p=m6w6%2Flibmemcached diff --git a/libhashkit/jenkins.c b/libhashkit/jenkins.c index 29d9454e..53e35a82 100644 --- a/libhashkit/jenkins.c +++ b/libhashkit/jenkins.c @@ -56,10 +56,11 @@ use a bitmask. For example, if you need only 10 bits, do In which case, the hash table should have hashsize(10) elements. */ -uint32_t hashkit_jenkins(const char *key, size_t length) +uint32_t hashkit_jenkins(const char *key, size_t length, void *context) { uint32_t a,b,c; /* internal state */ union { const void *ptr; size_t i; } u; /* needed for Mac Powerbook G4 */ + (void)context; /* Set up the internal state */ a = b = c = 0xdeadbeef + ((uint32_t)length) + JENKINS_INITVAL; @@ -82,7 +83,7 @@ uint32_t hashkit_jenkins(const char *key, size_t length) } /*----------------------------- handle the last (probably partial) block */ - /* + /* * "k[2]&0xffffff" actually reads beyond the end of the string, but * then masks off the part it's not allowed to read. Because the * string is aligned, the masked-off tail is in the same word as the @@ -109,7 +110,7 @@ uint32_t hashkit_jenkins(const char *key, size_t length) default: return c; } - } + } else if ((u.i & 0x1) == 0) { const uint16_t *k = (const uint16_t *)key; /* read 16-bit chunks */ @@ -159,7 +160,7 @@ uint32_t hashkit_jenkins(const char *key, size_t length) default: return c; } - } + } else { /* need to read the key one byte at a time */ #endif /* little endian */