]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - libiberty/calloc.c
import gdb-1999-08-16 snapshot
[thirdparty/binutils-gdb.git] / libiberty / calloc.c
1 #include "ansidecl.h"
2 #include "libiberty.h"
3
4 #ifdef ANSI_PROTOTYPES
5 #include <stddef.h>
6 #else
7 #define size_t unsigned long
8 #endif
9
10 /* For systems with larger pointers than ints, this must be declared. */
11 PTR malloc PARAMS ((size_t));
12
13 PTR
14 calloc (nelem, elsize)
15 size_t nelem, elsize;
16 {
17 register PTR ptr;
18
19 if (nelem == 0 || elsize == 0)
20 nelem = elsize = 1;
21
22 ptr = malloc (nelem * elsize);
23 if (ptr) bzero (ptr, nelem * elsize);
24
25 return ptr;
26 }