Remove OOM error handling code after calls to mf_hash_grow()

This commit is contained in:
Felipe Oliveira Carvalho 2014-04-04 16:39:57 -03:00 committed by Thiago de Arruda
parent b4545740fd
commit 457bb26151

View File

@ -91,7 +91,7 @@ static void mf_hash_free_all(mf_hashtab_T *);
static mf_hashitem_T *mf_hash_find(mf_hashtab_T *, blocknr_T); static mf_hashitem_T *mf_hash_find(mf_hashtab_T *, blocknr_T);
static void mf_hash_add_item(mf_hashtab_T *, mf_hashitem_T *); static void mf_hash_add_item(mf_hashtab_T *, mf_hashitem_T *);
static void mf_hash_rem_item(mf_hashtab_T *, mf_hashitem_T *); static void mf_hash_rem_item(mf_hashtab_T *, mf_hashitem_T *);
static int mf_hash_grow(mf_hashtab_T *); static void mf_hash_grow(mf_hashtab_T *);
/* /*
* The functions for using a memfile: * The functions for using a memfile:
@ -1226,10 +1226,7 @@ static void mf_hash_add_item(mf_hashtab_T *mht, mf_hashitem_T *mhi)
*/ */
if (mht->mht_fixed == 0 if (mht->mht_fixed == 0
&& (mht->mht_count >> MHT_LOG_LOAD_FACTOR) > mht->mht_mask) { && (mht->mht_count >> MHT_LOG_LOAD_FACTOR) > mht->mht_mask) {
if (mf_hash_grow(mht) == FAIL) { mf_hash_grow(mht);
/* stop trying to grow after first failure to allocate memory */
mht->mht_fixed = 1;
}
} }
} }
@ -1256,9 +1253,8 @@ static void mf_hash_rem_item(mf_hashtab_T *mht, mf_hashitem_T *mhi)
/* /*
* Increase number of buckets in the hashtable by MHT_GROWTH_FACTOR and * Increase number of buckets in the hashtable by MHT_GROWTH_FACTOR and
* rehash items. * rehash items.
* Returns FAIL when out of memory.
*/ */
static int mf_hash_grow(mf_hashtab_T *mht) static void mf_hash_grow(mf_hashtab_T *mht)
{ {
long_u i, j; long_u i, j;
int shift; int shift;
@ -1269,8 +1265,6 @@ static int mf_hash_grow(mf_hashtab_T *mht)
size = (mht->mht_mask + 1) * MHT_GROWTH_FACTOR * sizeof(void *); size = (mht->mht_mask + 1) * MHT_GROWTH_FACTOR * sizeof(void *);
buckets = (mf_hashitem_T **)lalloc_clear(size, FALSE); buckets = (mf_hashitem_T **)lalloc_clear(size, FALSE);
if (buckets == NULL)
return FAIL;
shift = 0; shift = 0;
while ((mht->mht_mask >> shift) != 0) while ((mht->mht_mask >> shift) != 0)
@ -1313,6 +1307,4 @@ static int mf_hash_grow(mf_hashtab_T *mht)
mht->mht_buckets = buckets; mht->mht_buckets = buckets;
mht->mht_mask = (mht->mht_mask + 1) * MHT_GROWTH_FACTOR - 1; mht->mht_mask = (mht->mht_mask + 1) * MHT_GROWTH_FACTOR - 1;
return OK;
} }