From cd571a9fa26391b9472c0643db7986b15d957f6d Mon Sep 17 00:00:00 2001 From: Vladimír Čunát Date: Tue, 19 Feb 2019 19:06:07 +0100 Subject: contrib/murmurhash3: fix bad type punning --- contrib/murmurhash3/murmurhash3.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'contrib') diff --git a/contrib/murmurhash3/murmurhash3.c b/contrib/murmurhash3/murmurhash3.c index 06ed7d84..ac28f699 100644 --- a/contrib/murmurhash3/murmurhash3.c +++ b/contrib/murmurhash3/murmurhash3.c @@ -2,6 +2,7 @@ * by its author, Austin Appleby. */ #include "murmurhash3.h" +#include "string.h" static inline uint32_t fmix(uint32_t h) { @@ -32,12 +33,11 @@ uint32_t hash(const char* data, size_t len_) //---------- // body - const uint32_t * blocks = (const uint32_t*) (data + nblocks * 4); - int i; for(i = -nblocks; i; i++) { - uint32_t k1 = blocks[i]; + uint32_t k1; + memcpy(&k1, data + nblocks * 4 + i * sizeof(k1), sizeof(k1)); k1 *= c1; k1 = rotl32(k1, 15); -- cgit v1.2.3