From 5315e3a597fca441d66e926ab20585b0ef735cec Mon Sep 17 00:00:00 2001 From: "Fabiano C. Botelho" Date: Sun, 27 Mar 2011 01:41:28 -0700 Subject: [PATCH] =?UTF-8?q?Committer:=20Fabiano=20C.=20Botelho=20=20On=20branch=20master=20Changes=20to=20?= =?UTF-8?q?be=20committed:=20Fixing=20bugs=20reported=20by=20Steve=20Fried?= =?UTF-8?q?man,=20Ka=C5=A1til=20Jan=20and=20a=20bug=20that=20was=20acciden?= =?UTF-8?q?tly=20introduced=20in=20file=20chd=5Fph.c=20in=201.0=20release.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit modified: src/bdz.c modified: src/bitbool.h modified: src/chd_ph.c modified: src/cmph_structs.c modified: src/hash.c --- src/bdz.c | 15 --------------- src/bitbool.h | 9 --------- src/chd_ph.c | 3 +-- src/cmph_structs.c | 2 +- src/hash.c | 5 ++++- 5 files changed, 6 insertions(+), 28 deletions(-) diff --git a/src/bdz.c b/src/bdz.c index a57f70f..e6ce700 100755 --- a/src/bdz.c +++ b/src/bdz.c @@ -560,21 +560,6 @@ void bdz_load(FILE *f, cmph_t *mphf) } -/* -static cmph_uint32 bdz_search_ph(cmph_t *mphf, const char *key, cmph_uint32 keylen) -{ - bdz_data_t *bdz = mphf->data; - cmph_uint32 hl[3]; - hash_vector(bdz->hl, key, keylen, hl); - cmph_uint32 vertex; - hl[0] = hl[0] % bdz->r; - hl[1] = hl[1] % bdz->r + bdz->r; - hl[2] = hl[2] % bdz->r + (bdz->r << 1); - vertex = hl[(GETVALUE(bdz->g, hl[0]) + GETVALUE(bdz->g, hl[1]) + GETVALUE(bdz->g, hl[2])) % 3]; - return vertex; -} -*/ - static inline cmph_uint32 rank(cmph_uint32 b, cmph_uint32 * ranktable, cmph_uint8 * g, cmph_uint32 vertex) { register cmph_uint32 index = vertex >> b; diff --git a/src/bitbool.h b/src/bitbool.h index a3286c3..a541ec0 100644 --- a/src/bitbool.h +++ b/src/bitbool.h @@ -31,15 +31,6 @@ static const cmph_uint8 valuemask[] = { 0xfc, 0xf3, 0xcf, 0x3f}; */ #define SETBIT(array, i) (array[i >> 3] |= bitmask[i & 0x00000007]) -/** \def UNSETBIT(array, i) - * \brief set 0 to an 1-bit integer stored in an array. - * \param array to store 1-bit integer values - * \param i is the index in array to set the the bit to 0 - * - * UNSETBIT(array, i) is a macro that sets 0 to an 1-bit integer stored in an array. - */ -#define UNSETBIT(array, i) (array[i >> 3] ^= ((bitmask[i & 0x00000007]))) - //#define GETBIT(array, i) (array[(i) / 8] & bitmask[(i) % 8]) //#define SETBIT(array, i) (array[(i) / 8] |= bitmask[(i) % 8]) //#define UNSETBIT(array, i) (array[(i) / 8] ^= ((bitmask[(i) % 8]))) diff --git a/src/chd_ph.c b/src/chd_ph.c index cf877af..71f83fb 100644 --- a/src/chd_ph.c +++ b/src/chd_ph.c @@ -625,7 +625,7 @@ cmph_t *chd_ph_new(cmph_config_t *mph, double c) chd_ph_data_t *chd_phf = NULL; chd_ph_config_data_t *chd_ph = (chd_ph_config_data_t *)mph->data; - register double load_factor = 0.6; + register double load_factor = c; register cmph_uint8 searching_success = 0; register cmph_uint32 max_probes = 1 << 20; // default value for max_probes register cmph_uint32 iterations = 100; @@ -641,7 +641,6 @@ cmph_t *chd_ph_new(cmph_config_t *mph, double c) double construction_time = 0.0; ELAPSED_TIME_IN_SECONDS(&construction_time_begin); #endif - c = load_factor; chd_ph->m = mph->key_source->nkeys; diff --git a/src/cmph_structs.c b/src/cmph_structs.c index b563424..bcd3da3 100644 --- a/src/cmph_structs.c +++ b/src/cmph_structs.c @@ -8,8 +8,8 @@ cmph_config_t *__config_new(cmph_io_adapter_t *key_source) { cmph_config_t *mph = (cmph_config_t *)malloc(sizeof(cmph_config_t)); - memset(mph, 0, sizeof(cmph_config_t)); if (mph == NULL) return NULL; + memset(mph, 0, sizeof(cmph_config_t)); mph->key_source = key_source; mph->verbosity = 0; mph->data = NULL; diff --git a/src/hash.c b/src/hash.c index be86d6e..7ab0b04 100644 --- a/src/hash.c +++ b/src/hash.c @@ -59,7 +59,9 @@ void hash_state_dump(hash_state_t *state, char **buf, cmph_uint32 *buflen) { case CMPH_HASH_JENKINS: jenkins_state_dump((jenkins_state_t *)state, &algobuf, buflen); - if (*buflen == UINT_MAX) return; + if (*buflen == UINT_MAX) { + goto cmph_cleanup; + } break; default: assert(0); @@ -70,6 +72,7 @@ void hash_state_dump(hash_state_t *state, char **buf, cmph_uint32 *buflen) len = *buflen; memcpy(*buf + strlen(cmph_hash_names[state->hashfunc]) + 1, algobuf, len); *buflen = (cmph_uint32)strlen(cmph_hash_names[state->hashfunc]) + 1 + *buflen; +cmph_cleanup: free(algobuf); return; }