summaryrefslogtreecommitdiff
path: root/libc/stdlib/malloc/calloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/stdlib/malloc/calloc.c')
-rw-r--r--libc/stdlib/malloc/calloc.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/libc/stdlib/malloc/calloc.c b/libc/stdlib/malloc/calloc.c
new file mode 100644
index 000000000..6231edb46
--- /dev/null
+++ b/libc/stdlib/malloc/calloc.c
@@ -0,0 +1,32 @@
+/*
+ * libc/stdlib/malloc-zarg/calloc.c -- calloc function
+ *
+ * Copyright (C) 2002 NEC Corporation
+ * Copyright (C) 2002 Miles Bader <miles@gnu.org>
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser
+ * General Public License. See the file COPYING.LIB in the main
+ * directory of this archive for more details.
+ *
+ * Written by Miles Bader <miles@gnu.org>
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "malloc.h"
+
+
+void *
+calloc (size_t size, size_t num)
+{
+ void *mem;
+
+ size *= num;
+
+ mem = malloc (size);
+ if (mem)
+ memset (mem, 0, size);
+
+ return mem;
+}