diff options
Diffstat (limited to 'usr.sbin/unbound/ldns/compat/calloc.c')
-rw-r--r-- | usr.sbin/unbound/ldns/compat/calloc.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/usr.sbin/unbound/ldns/compat/calloc.c b/usr.sbin/unbound/ldns/compat/calloc.c new file mode 100644 index 00000000000..c86b956757f --- /dev/null +++ b/usr.sbin/unbound/ldns/compat/calloc.c @@ -0,0 +1,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; +} + |