diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/dict.c | 9 | ||||
-rw-r--r-- | src/dict.h | 5 |
2 files changed, 4 insertions, 10 deletions
diff --git a/src/dict.c b/src/dict.c index 21c616e6f..f10d0ca36 100644 --- a/src/dict.c +++ b/src/dict.c @@ -381,7 +381,7 @@ dictEntry *dictAddOrFind(dict *d, void *key) { return entry ? entry : existing; } -/* Search and remove an element. This is an helper function for +/* Search and remove an element. This is a helper function for * dictDelete() and dictUnlink(), please check the top comment * of those functions. */ static dictEntry *dictGenericDelete(dict *d, const void *key, int nofree) { @@ -389,7 +389,8 @@ static dictEntry *dictGenericDelete(dict *d, const void *key, int nofree) { dictEntry *he, *prevHe; int table; - if (d->ht[0].used == 0 && d->ht[1].used == 0) return NULL; + /* dict is empty */ + if (dictSize(d) == 0) return NULL; if (dictIsRehashing(d)) _dictRehashStep(d); h = dictHashKey(d, key); @@ -406,9 +407,7 @@ static dictEntry *dictGenericDelete(dict *d, const void *key, int nofree) { else d->ht[table].table[idx] = he->next; if (!nofree) { - dictFreeKey(d, he); - dictFreeVal(d, he); - zfree(he); + dictFreeUnlinkedEntry(d, he); } d->ht[table].used--; return he; diff --git a/src/dict.h b/src/dict.h index 7e2258960..02af65cf8 100644 --- a/src/dict.h +++ b/src/dict.h @@ -196,11 +196,6 @@ unsigned long dictScan(dict *d, unsigned long v, dictScanFunction *fn, dictScanB uint64_t dictGetHash(dict *d, const void *key); dictEntry **dictFindEntryRefByPtrAndHash(dict *d, const void *oldptr, uint64_t hash); -/* Hash table types */ -extern dictType dictTypeHeapStringCopyKey; -extern dictType dictTypeHeapStrings; -extern dictType dictTypeHeapStringCopyKeyValue; - #ifdef REDIS_TEST int dictTest(int argc, char *argv[], int accurate); #endif |