aboutsummaryrefslogtreecommitdiff
path: root/libiberty/calloc.c
diff options
context:
space:
mode:
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>1998-11-13 16:36:04 +0000
committerKaveh Ghazi <ghazi@gcc.gnu.org>1998-11-13 16:36:04 +0000
commita9acf74156d05a933295cba9b800c2c6759296f5 (patch)
tree3ba8d1fed8bcc7504da2c11d5b6e63f2bdf140e3 /libiberty/calloc.c
parent67d0f6ab5e3c6fba25e59702f09f44694a0c968b (diff)
downloadgcc-a9acf74156d05a933295cba9b800c2c6759296f5.zip
gcc-a9acf74156d05a933295cba9b800c2c6759296f5.tar.gz
gcc-a9acf74156d05a933295cba9b800c2c6759296f5.tar.bz2
configure.in: Check for calloc.
* configure.in: Check for calloc. * calloc.c: New file. * xmalloc.c (xcalloc): New function. From-SVN: r23642
Diffstat (limited to 'libiberty/calloc.c')
-rw-r--r--libiberty/calloc.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/libiberty/calloc.c b/libiberty/calloc.c
new file mode 100644
index 0000000..c8c0a78
--- /dev/null
+++ b/libiberty/calloc.c
@@ -0,0 +1,26 @@
+#include "ansidecl.h"
+#include "libiberty.h"
+
+#ifdef ANSI_PROTOTYPES
+#include <stddef.h>
+#else
+#define size_t unsigned long
+#endif
+
+/* For systems with larger pointers than ints, this must be declared. */
+PTR malloc PARAMS ((size_t));
+
+PTR
+calloc (nelem, elsize)
+ size_t nelem, elsize;
+{
+ register PTR ptr;
+
+ if (nelem == 0 || elsize == 0)
+ nelem = elsize = 1;
+
+ ptr = malloc (nelem * elsize);
+ if (ptr) bzero (ptr, nelem * elsize);
+
+ return ptr;
+}