summaryrefslogtreecommitdiff
path: root/compat/calloc.c
blob: c86b956757f1231ac401a4f0714e9a66b05e8404 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* Just a replacement, if the original malloc is not
   GNU-compliant. See autoconf documentation. */

#if HAVE_CONFIG_H
#include <ldns/config.h>
#endif

void *calloc();

#if !HAVE_BZERO && HAVE_MEMSET
# define bzero(buf, bytes)	((void) memset (buf, 0, bytes))
#endif

void *
calloc(size_t num, size_t size)
{
	void *new = malloc(num * size);
	if (!new) {
		return NULL;
	}
	bzero(new, num * size);
	return new;
}