Permalink
Browse files

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.
  • Loading branch information...
1 parent 391f2e4 commit 984053cd686fc33ab942f01038737eab12f45c36 @dustin dustin committed Jun 18, 2008
Showing with 1 addition and 3 deletions.
  1. +1 −3 assoc.c
View
@@ -476,13 +476,11 @@ static bool expanding = false;
static unsigned int expand_bucket = 0;
void assoc_init(void) {
- unsigned int hash_size = hashsize(hashpower) * sizeof(void*);
- primary_hashtable = malloc(hash_size);
+ primary_hashtable = calloc(hashsize(hashpower), sizeof(void *));
if (! primary_hashtable) {
fprintf(stderr, "Failed to init hashtable.\n");
exit(EXIT_FAILURE);
}
- memset(primary_hashtable, 0, hash_size);
}
item *assoc_find(const char *key, const size_t nkey) {

0 comments on commit 984053c

Please sign in to comment.