|
Last change
on this file since 490 was 10, checked in by bird, 23 years ago |
|
Initial revision
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
|
|
File size:
578 bytes
|
| Line | |
|---|
| 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 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.