1 /* calloc -- allocate memory which has been initialized to zero.
2 This function is in the public domain. */
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.
16 #include "libiberty.h"
18 #ifdef ANSI_PROTOTYPES
21 #define size_t unsigned long
24 /* For systems with larger pointers than ints, this must be declared. */
25 PTR malloc
PARAMS ((size_t));
28 calloc (nelem
, elsize
)
33 if (nelem
== 0 || elsize
== 0)
36 ptr
= malloc (nelem
* elsize
);
37 if (ptr
) bzero (ptr
, nelem
* elsize
);