Hackfix and re-enable strtoull and wcstoull, see bug #3798.
[sdcc.git] / sdcc / support / sdbinutils / libiberty / calloc.c
blobf4bd27b1cd2a460c89c1e5ba2e3e94190db98c85
1 /* calloc -- allocate memory which has been initialized to zero.
2 This function is in the public domain. */
4 /*
6 @deftypefn Supplemental void* calloc (size_t @var{nelem}, size_t @var{elsize})
8 Uses @code{malloc} to allocate storage for @var{nelem} objects of
9 @var{elsize} bytes each, then zeros the memory.
11 @end deftypefn
15 #include "ansidecl.h"
16 #include <stddef.h>
18 /* For systems with larger pointers than ints, this must be declared. */
19 PTR malloc (size_t);
20 void bzero (PTR, size_t);
22 PTR
23 calloc (size_t nelem, size_t elsize)
25 register PTR ptr;
27 if (nelem == 0 || elsize == 0)
28 nelem = elsize = 1;
30 ptr = malloc (nelem * elsize);
31 if (ptr) bzero (ptr, nelem * elsize);
33 return ptr;