From 3c3256c5c0ca81486df3aaddf95e76d73849ba7f Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Wed, 14 Jan 2009 20:07:47 +0100 Subject: hashtable: use calloc instead of malloc + memset This patch is a cleanup, use calloc instead of malloc + memset. Signed-off-by: Pablo Neira Ayuso --- src/hash.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/hash.c b/src/hash.c index efc6a18..a7c7536 100644 --- a/src/hash.c +++ b/src/hash.c @@ -30,10 +30,9 @@ struct hashtable_node *hashtable_alloc_node(int datasize, void *data) struct hashtable_node *n; int size = sizeof(struct hashtable_node) + datasize; - n = malloc(size); + n = calloc(size, 1); if (!n) return NULL; - memset(n, 0, size); memcpy(n->data, data, datasize); return n; @@ -55,13 +54,12 @@ hashtable_create(int hashsize, int limit, int datasize, int size = sizeof(struct hashtable) + hashsize * sizeof(struct slist_head); - h = (struct hashtable *) malloc(size); + h = (struct hashtable *) calloc(size, 1); if (!h) { errno = ENOMEM; return NULL; } - memset(h, 0, size); for (i=0; imembers[i]); -- cgit v1.2.3