X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fjenkins_hash.c;h=e84cf3edefc0af9c829f792e933e4dfe60611cd4;hb=a7a011c2ea4a63368b3a96a332da00820ed402cb;hp=409a405400e46e875a4d3ef4e3cb893a57f7fad8;hpb=7e0ffed050b62cc5dcf5d16c148185074bfd7d50;p=m6w6%2Flibmemcached diff --git a/libmemcached/jenkins_hash.c b/libmemcached/jenkins_hash.c index 409a4054..e84cf3ed 100644 --- a/libmemcached/jenkins_hash.c +++ b/libmemcached/jenkins_hash.c @@ -63,6 +63,7 @@ uint32_t jenkins_hash(const void *key, size_t length, uint32_t initval) a = b = c = 0xdeadbeef + ((uint32_t)length) + initval; u.ptr = key; +#ifdef BYTEORDER_LITTLE_ENDIAN if ((u.i & 0x3) == 0) { const uint32_t *k = (const uint32_t *)key; /* read 32-bit chunks */ @@ -103,6 +104,7 @@ uint32_t jenkins_hash(const void *key, size_t length, uint32_t initval) case 2 : a+=k[0]&0xffff; break; case 1 : a+=k[0]&0xff; break; case 0 : return c; /* zero length strings require no mixing */ + default: return c; } } @@ -152,11 +154,13 @@ uint32_t jenkins_hash(const void *key, size_t length, uint32_t initval) case 1 : a+=k8[0]; break; case 0 : return c; /* zero length requires no mixing */ + default: return c; } } else { /* need to read the key one byte at a time */ +#endif /* little endian */ const uint8_t *k = (const uint8_t *)key; /*--------------- all but the last block: affect some 32 bits of (a,b,c) */ @@ -196,8 +200,11 @@ uint32_t jenkins_hash(const void *key, size_t length, uint32_t initval) case 1 : a+=k[0]; break; case 0 : return c; + default : return c; } +#ifdef BYTEORDER_LITTLE_ENDIAN } +#endif final(a,b,c); return c;