summaryrefslogtreecommitdiff
path: root/sys/src/libc
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2016-11-05 18:00:10 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2016-11-05 18:00:10 +0100
commit5c1feb0ef0b795e5de71e956f9ccddcd5c4b7f21 (patch)
treece10dae7b7edc23f0a69fecaae8b3ed62e2a39eb /sys/src/libc
parentbf9bada0c246ef96ee168e355b26e4dc67396ee4 (diff)
libc: move calloc() into its own compilation unit
move calloc() in its own compilation unit to avoid code duplication. also, calloc() is used rarely in plan9 programs.
Diffstat (limited to 'sys/src/libc')
-rw-r--r--sys/src/libc/port/calloc.c13
-rw-r--r--sys/src/libc/port/malloc.c12
-rw-r--r--sys/src/libc/port/mkfile1
3 files changed, 14 insertions, 12 deletions
diff --git a/sys/src/libc/port/calloc.c b/sys/src/libc/port/calloc.c
new file mode 100644
index 000000000..b8319128f
--- /dev/null
+++ b/sys/src/libc/port/calloc.c
@@ -0,0 +1,13 @@
+#include <u.h>
+#include <libc.h>
+
+void*
+calloc(ulong n, ulong s)
+{
+ void *v;
+ if(n > 1 && ((ulong)-1)/n < s)
+ return nil;
+ if(v = mallocz(n*s, 1))
+ setmalloctag(v, getcallerpc(&n));
+ return v;
+}
diff --git a/sys/src/libc/port/malloc.c b/sys/src/libc/port/malloc.c
index a96ff8f78..907bfa8a6 100644
--- a/sys/src/libc/port/malloc.c
+++ b/sys/src/libc/port/malloc.c
@@ -279,18 +279,6 @@ msize(void *v)
return poolmsize(mainmem, (ulong*)v-Npadlong)-Npadlong*sizeof(ulong);
}
-void*
-calloc(ulong n, ulong s)
-{
- void *v;
-
- if(n > 1 && ((ulong)-1)/n < s)
- return nil;
- if(v = mallocz(n*s, 1))
- setmalloctag(v, getcallerpc(&n));
- return v;
-}
-
void
setmalloctag(void *v, uintptr pc)
{
diff --git a/sys/src/libc/port/mkfile b/sys/src/libc/port/mkfile
index dc2d93694..f3d32aaca 100644
--- a/sys/src/libc/port/mkfile
+++ b/sys/src/libc/port/mkfile
@@ -12,6 +12,7 @@ CFILES=\
atof.c\
atol.c\
atoll.c\
+ calloc.c\
cistrcmp.c\
cistrncmp.c\
cistrstr.c\