X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fjenkins_hash.c;h=e4aa4f19da0b4535535260516ed0c670c43679a5;hb=3928e14fbe1ed17cefe9bdbbb282fb7ecf053e7a;hp=940e4718c0810ae976a85e822383269ddbc4e6be;hpb=7a85b394e18dc4d8b1450174372d45eff846b908;p=m6w6%2Flibmemcached diff --git a/libmemcached/jenkins_hash.c b/libmemcached/jenkins_hash.c index 940e4718..e4aa4f19 100644 --- a/libmemcached/jenkins_hash.c +++ b/libmemcached/jenkins_hash.c @@ -63,7 +63,9 @@ uint32_t jenkins_hash(const void *key, size_t length, uint32_t initval) a = b = c = 0xdeadbeef + ((uint32_t)length) + initval; u.ptr = key; - if ((u.i & 0x3) == 0) { +#ifndef WORDS_BIGENDIAN + if ((u.i & 0x3) == 0) + { const uint32_t *k = (const uint32_t *)key; /* read 32-bit chunks */ /*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */ @@ -102,9 +104,12 @@ 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; } - } else if ((u.i & 0x1) == 0) { + } + else if ((u.i & 0x1) == 0) + { const uint16_t *k = (const uint16_t *)key; /* read 16-bit chunks */ const uint8_t *k8; @@ -149,9 +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 */ + } + 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) */ @@ -191,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; } +#ifndef WORDS_BIGENDIAN } +#endif final(a,b,c); return c;