Take the 2008 Git User's Survey and help out! [ hide ]

public
Description: This is where my memcached work lives before svn munges the changes.
Homepage: http://www.danga.com/memcached/
Clone URL: git://github.com/dustin/memcached.git
Search Repo:
Use calloc for allocating the hash table vs. malloc+memset.

calloc is already used to resize the hash table, so it's good to be
consistent here.
dustin (author)
Wed Jun 18 11:30:22 -0700 2008
commit  0ebdf6d38cd65cca31885e8e7e2f4c7ac4888279
tree    a8237b3f6ea4bb90137613f49ac4c1ce22ce0aaf
parent  6ec16c4ad2e8274e23d3c1c2111a8a6a2f99d3b4
...
476
477
478
479
480
 
481
482
483
484
485
486
487
488
...
476
477
478
 
 
479
480
481
482
483
 
484
485
486
0
@@ -476,13 +476,11 @@ static bool expanding = false;
0
 static unsigned int expand_bucket = 0;
0
 
0
 void assoc_init(void) {
0
- unsigned int hash_size = hashsize(hashpower) * sizeof(void*);
0
- primary_hashtable = malloc(hash_size);
0
+ primary_hashtable = calloc(hashsize(hashpower), sizeof(void *));
0
     if (! primary_hashtable) {
0
         fprintf(stderr, "Failed to init hashtable.\n");
0
         exit(EXIT_FAILURE);
0
     }
0
- memset(primary_hashtable, 0, hash_size);
0
 }
0
 
0
 item *assoc_find(const char *key, const size_t nkey) {

Comments

    No one has commented yet.