X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/d9dd352b3693e1ad8ab2e0993b4f0a275d7fd512..73db2acc374c99ca8224e44a7383f69e7ca24a4f:/src/dict.c diff --git a/src/dict.c b/src/dict.c index 0d4aacb7..2d1e752b 100644 --- a/src/dict.c +++ b/src/dict.c @@ -148,14 +148,12 @@ int dictExpand(dict *d, unsigned long size) if (dictIsRehashing(d) || d->ht[0].used > size) return DICT_ERR; + /* Allocate the new hashtable and initialize all pointers to NULL */ n.size = realsize; n.sizemask = realsize-1; - n.table = zmalloc(realsize*sizeof(dictEntry*)); + n.table = zcalloc(realsize*sizeof(dictEntry*)); n.used = 0; - /* Initialize all the pointers to NULL */ - memset(n.table, 0, realsize*sizeof(dictEntry*)); - /* Is this the first initialization? If so it's not really a rehashing * we just set the first hash table so that it can accept keys. */ if (d->ht[0].table == NULL) { @@ -617,6 +615,12 @@ void dictDisableResize(void) { dict_can_resize = 0; } +#if 0 + +/* The following are just example hash table types implementations. + * Not useful for Redis so they are commented out. + */ + /* ----------------------- StringCopy Hash Table Type ------------------------*/ static unsigned int _dictStringCopyHTHashFunction(const void *key) @@ -680,3 +684,4 @@ dictType dictTypeHeapStringCopyKeyValue = { _dictStringDestructor, /* key destructor */ _dictStringDestructor, /* val destructor */ }; +#endif