commit f1b55c5c7ba141a313bdef015e1b820cdb60483e from: Thomas Adam date: Sat Jul 16 20:01:53 2022 UTC portable: update murmurhash2.c This brings the file in-line with upstream. commit - 65ad15fa440d89e976ce1bd3bd02d5440e86d5d3 commit + f1b55c5c7ba141a313bdef015e1b820cdb60483e blob - ac869f866068f2b1050c52779f2539890a8c877f blob + d3a67547fa3ddbd12660f688766bd387d6ed905b --- lib/murmurhash2.c +++ lib/murmurhash2.c @@ -5,11 +5,12 @@ /* Obtained from https://github.com/aappleby/smhasher */ #include +#include #include "murmurhash2.h" uint32_t -murmurhash2(const void * key, int len, uint32_t seed) +murmurhash2(const unsigned char * key, int len, uint32_t seed) { // 'm' and 'r' are mixing constants generated offline. // They're not really 'magic', they just happen to work well. @@ -23,12 +24,14 @@ murmurhash2(const void * key, int len, uint32_t seed) // Mix 4 bytes at a time into the hash - const unsigned char *data = (const unsigned char *)key; + const unsigned char *data = key; while(len >= 4) { - uint32_t k = *(uint32_t*)data; + uint32_t k; + memcpy(&k, data, sizeof(k)); + k *= m; k ^= k >> r; k *= m; @@ -58,4 +61,4 @@ murmurhash2(const void * key, int len, uint32_t seed) h ^= h >> 15; return h; -} +} blob - bbd2bf3ef0309efebdfbb79dd75aa100d4fb0b74 blob + 8fa42cdb7d310218bbaff43e40157c42561bdebd --- lib/murmurhash2.h +++ lib/murmurhash2.h @@ -4,4 +4,4 @@ /* Obtained from https://github.com/aappleby/smhasher */ -uint32_t murmurhash2(const void *key, int len, uint32_t seed); +uint32_t murmurhash2(const unsigned char *key, int len, uint32_t seed);