| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Memcached
Revision: 785
Author: dormando
Date: 23 Jun 2008 00:05:13
Changes: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.
| ... | ...@@ -476,13 +476,11 @@ | |
| 476 | 476 | static unsigned int expand_bucket = 0; |
| 477 | 477 | |
| 478 | 478 | void assoc_init(void) { |
| 479 | unsigned int hash_size = hashsize(hashpower) * sizeof(void*); | |
| 480 | primary_hashtable = malloc(hash_size); | |
| 479 | primary_hashtable = calloc(hashsize(hashpower), sizeof(void *)); | |
| 481 | 480 | if (! primary_hashtable) { |
| 482 | 481 | fprintf(stderr, "Failed to init hashtable.\n"); |
| 483 | 482 | exit(EXIT_FAILURE); |
| 484 | 483 | } |
| 485 | memset(primary_hashtable, 0, hash_size); | |
| 486 | 484 | } |
| 487 | 485 | |
| 488 | 486 | item *assoc_find(const char *key, const size_t nkey) { |