xref: /freebsd/contrib/ldns/compat/calloc.c (revision 7b5038d7)
1 /* Just a replacement, if the original malloc is not
2    GNU-compliant. See autoconf documentation. */
3 
4 #if HAVE_CONFIG_H
5 #include <ldns/config.h>
6 #endif
7 
8 void *calloc();
9 
10 #if !HAVE_BZERO && HAVE_MEMSET
11 # define bzero(buf, bytes)	((void) memset (buf, 0, bytes))
12 #endif
13 
14 void *
calloc(size_t num,size_t size)15 calloc(size_t num, size_t size)
16 {
17 	void *new = malloc(num * size);
18 	if (!new) {
19 		return NULL;
20 	}
21 	bzero(new, num * size);
22 	return new;
23 }
24 
25