diff options
| author | Pablo Neira Ayuso <pablo@netfilter.org> | 2009-01-14 20:07:47 +0100 | 
|---|---|---|
| committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2009-01-14 20:07:47 +0100 | 
| commit | 3c3256c5c0ca81486df3aaddf95e76d73849ba7f (patch) | |
| tree | fdcfc57c2171107af2cc974d8e367f3202112508 | |
| parent | 3e353c58a138d87ae31a9a18ec716c08ba3dc3cf (diff) | |
| download | conntrack-tools-3c3256c5c0ca81486df3aaddf95e76d73849ba7f.tar.gz conntrack-tools-3c3256c5c0ca81486df3aaddf95e76d73849ba7f.zip  | |
hashtable: use calloc instead of malloc + memset
This patch is a cleanup, use calloc instead of malloc + memset.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
| -rw-r--r-- | src/hash.c | 6 | 
1 files changed, 2 insertions, 4 deletions
@@ -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; i<hashsize; i++)  		INIT_SLIST_HEAD(h->members[i]);  | 
