summaryrefslogtreecommitdiff
path: root/libc/stdlib/malloc-930716/calloc.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-01-11 11:42:17 +0000
committerEric Andersen <andersen@codepoet.org>2001-01-11 11:42:17 +0000
commitae97a89e1a1a9833080dccc81f6cd26784e1b964 (patch)
tree6ff1ddc7e3980591c7fd0bbd5d9b8ac82da12886 /libc/stdlib/malloc-930716/calloc.c
parentabdc3e4d06db2b9d93c509774fc7c4fde918ec8e (diff)
A large update from Manuel Novoa III <mnovoa3@bellsouth.net>.
Diffstat (limited to 'libc/stdlib/malloc-930716/calloc.c')
-rw-r--r--libc/stdlib/malloc-930716/calloc.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/libc/stdlib/malloc-930716/calloc.c b/libc/stdlib/malloc-930716/calloc.c
new file mode 100644
index 000000000..152fe09c6
--- /dev/null
+++ b/libc/stdlib/malloc-930716/calloc.c
@@ -0,0 +1,25 @@
+/* calloc.c - C standard library routine.
+ Copyright (c) 1989, 1993 Michael J. Haertel
+ You may redistribute this library under the terms of the
+ GNU Library General Public License (version 2 or any later
+ version) as published by the Free Software Foundation.
+ THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED
+ WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION OR
+ WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS
+ SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. */
+
+#include <string.h>
+#include "malloc.h"
+
+/* Allocate space for the given number of elements of the given
+ size, initializing the whole region to binary zeroes. */
+void *
+calloc(size_t nelem, size_t size)
+{
+ void *result;
+
+ result = malloc(size * nelem);
+ if (result)
+ memset(result, 0, nelem * size);
+ return result;
+}