From 60c7388bd69bc9f650246465639a1c751287df76 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Thu, 17 Aug 2017 20:35:16 +0200 Subject: [PATCH] Fix a hash function. --- m-core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/m-core.h b/m-core.h index ba6c7c96..fa9d8098 100644 --- a/m-core.h +++ b/m-core.h @@ -655,7 +655,7 @@ #define M_HASH_CALC(h1,h2) ((h2) + ((h1) << 6) + ((h1) << 16) - (h1)) #elif defined(M_USE_DEKHASH) #define M_HASH_INIT 0UL /* should be len but not possible with interface */ -#define M_HASH_CALC(h1,h2) (((h1)<<5) ^ (h1 >> 27) ^(h2)) +#define M_HASH_CALC(h1,h2) ( (((h1)<<5) | (h1 >> (CHAR_BIT*sizeof(size_t)-5))) ^(h2)) #elif defined(M_USE_BPHASH) #define M_HASH_INIT 0UL #define M_HASH_CALC(h1,h2) (((h1) << 7) ^ (h2))