summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven J. Magnani <steve@digidescorp.com>2010-06-09 09:02:21 -0500
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2010-07-27 13:30:00 +0200
commitafd7606ca42a2586b8823c7bd1a4a7cfd2476e3b (patch)
tree608718f58093cede57ae9526187902156dafd141
parentf6651fa449e1d4bbbb466b091f34e6752f6506f9 (diff)
downloaduClibc-alpine-afd7606ca42a2586b8823c7bd1a4a7cfd2476e3b.tar.bz2
uClibc-alpine-afd7606ca42a2586b8823c7bd1a4a7cfd2476e3b.tar.xz
malloc-simple: Make calloc() return zeroed memory
The 0.9.31 release included a change to malloc-simple to request uninitialized memory from noMMU kernels. Unfortunately, the corresponding calloc() code assumed that memory returned by malloc() was already zeroed, which leads to all kinds of nastiness. Signed-off-by: Steven J. Magnani <steve@digidescorp.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
-rw-r--r--libc/stdlib/malloc-simple/alloc.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/libc/stdlib/malloc-simple/alloc.c b/libc/stdlib/malloc-simple/alloc.c
index 51da14ac8..914c89dc0 100644
--- a/libc/stdlib/malloc-simple/alloc.c
+++ b/libc/stdlib/malloc-simple/alloc.c
@@ -60,11 +60,10 @@ void * calloc(size_t nmemb, size_t lsize)
__set_errno(ENOMEM);
return NULL;
}
- result=malloc(size);
-#if 0
- /* Standard unix mmap using /dev/zero clears memory so calloc
- * doesn't need to actually zero anything....
- */
+ result = malloc(size);
+
+#ifndef __ARCH_USE_MMU__
+ /* mmap'd with MAP_UNINITIALIZE, we have to blank memory ourselves */
if (result != NULL) {
memset(result, 0, size);
}