This commit was generated by cvs2svn to track changes on a CVS vendor
[deliverable/binutils-gdb.git] / libiberty / calloc.c
1 /* calloc -- allocate memory which has been initialized to zero.
2 This function is in the public domain. */
3
4 #include "ansidecl.h"
5 #include "libiberty.h"
6
7 #ifdef ANSI_PROTOTYPES
8 #include <stddef.h>
9 #else
10 #define size_t unsigned long
11 #endif
12
13 /* For systems with larger pointers than ints, this must be declared. */
14 PTR malloc PARAMS ((size_t));
15
16 PTR
17 calloc (nelem, elsize)
18 size_t nelem, elsize;
19 {
20 register PTR ptr;
21
22 if (nelem == 0 || elsize == 0)
23 nelem = elsize = 1;
24
25 ptr = malloc (nelem * elsize);
26 if (ptr) bzero (ptr, nelem * elsize);
27
28 return ptr;
29 }
This page took 0.035076 seconds and 5 git commands to generate.