]> git.saurik.com Git - redis.git/commitdiff
dict.c fixed to play well with enabling/disabling of the hash table
authorantirez <antirez@gmail.com>
Sat, 10 Apr 2010 09:14:11 +0000 (11:14 +0200)
committerantirez <antirez@gmail.com>
Sat, 10 Apr 2010 09:14:11 +0000 (11:14 +0200)
dict.c

diff --git a/dict.c b/dict.c
index 64e9eacf030d3d93936cffbe3de9a40a32bb47d5..150a0e3d7570bf59aebc2fa3a62eb8f97db78a29 100644 (file)
--- a/dict.c
+++ b/dict.c
@@ -425,7 +425,7 @@ static int _dictExpandIfNeeded(dict *ht)
     if (ht->size == 0)
         return dictExpand(ht, DICT_HT_INITIAL_SIZE);
     if (ht->used >= ht->size && dict_can_resize)
-        return dictExpand(ht, ht->size*2);
+        return dictExpand(ht, ((ht->size > ht->used) ? ht->size : ht->used)*2);
     return DICT_OK;
 }
 
@@ -519,7 +519,7 @@ void dictEnableResize(void) {
 }
 
 void dictDisableResize(void) {
-    dict_can_resize = 1;
+    dict_can_resize = 0;
 }
 
 /* ----------------------- StringCopy Hash Table Type ------------------------*/