From 9e434d41d0ac14ff70d700c27716b30a095f7071 Mon Sep 17 00:00:00 2001 From: "Fabiano C. Botelho" Date: Tue, 16 Apr 2013 00:16:49 -0700 Subject: [PATCH] Applying Michael Samuel's patch to fix a bug in jenkins_hash. This will break compatibility with mphf previously generated. If someone has functions stored they will need to either change this function back and keep using the buggy version or regenerate them. --- src/jenkins_hash.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/jenkins_hash.c b/src/jenkins_hash.c index d540216..13c50d6 100644 --- a/src/jenkins_hash.c +++ b/src/jenkins_hash.c @@ -98,7 +98,7 @@ void jenkins_state_destroy(jenkins_state_t *state) } -static inline void __jenkins_hash_vector(cmph_uint32 seed, const char *k, cmph_uint32 keylen, cmph_uint32 * hashes) +static inline void __jenkins_hash_vector(cmph_uint32 seed, const unsigned char *k, cmph_uint32 keylen, cmph_uint32 * hashes) { register cmph_uint32 len, length; @@ -154,7 +154,7 @@ static inline void __jenkins_hash_vector(cmph_uint32 seed, const char *k, cmph_u cmph_uint32 jenkins_hash(jenkins_state_t *state, const char *k, cmph_uint32 keylen) { cmph_uint32 hashes[3]; - __jenkins_hash_vector(state->seed, k, keylen, hashes); + __jenkins_hash_vector(state->seed, (const unsigned char*)k, keylen, hashes); return hashes[2]; /* cmph_uint32 a, b, c; cmph_uint32 len, length; @@ -215,7 +215,7 @@ cmph_uint32 jenkins_hash(jenkins_state_t *state, const char *k, cmph_uint32 keyl void jenkins_hash_vector_(jenkins_state_t *state, const char *k, cmph_uint32 keylen, cmph_uint32 * hashes) { - __jenkins_hash_vector(state->seed, k, keylen, hashes); + __jenkins_hash_vector(state->seed, (const unsigned char*)k, keylen, hashes); } void jenkins_state_dump(jenkins_state_t *state, char **buf, cmph_uint32 *buflen) @@ -282,7 +282,7 @@ cmph_uint32 jenkins_state_packed_size(void) cmph_uint32 jenkins_hash_packed(void *jenkins_packed, const char *k, cmph_uint32 keylen) { cmph_uint32 hashes[3]; - __jenkins_hash_vector(*((cmph_uint32 *)jenkins_packed), k, keylen, hashes); + __jenkins_hash_vector(*((cmph_uint32 *)jenkins_packed), (const unsigned char*)k, keylen, hashes); return hashes[2]; } @@ -294,5 +294,5 @@ cmph_uint32 jenkins_hash_packed(void *jenkins_packed, const char *k, cmph_uint32 */ void jenkins_hash_vector_packed(void *jenkins_packed, const char *k, cmph_uint32 keylen, cmph_uint32 * hashes) { - __jenkins_hash_vector(*((cmph_uint32 *)jenkins_packed), k, keylen, hashes); + __jenkins_hash_vector(*((cmph_uint32 *)jenkins_packed), (const unsigned char*)k, keylen, hashes); }