[PATCH][noMMU] malloc-simple: Make calloc() return zeroed memory
Steven J. Magnani
steve at digidescorp.com
Wed Jun 9 14:02:21 UTC 2010
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 at digidescorp.com>
---
diff -uprN a/libc/stdlib/malloc-simple/alloc.c b/libc/stdlib/malloc-simple/alloc.c
--- a/libc/stdlib/malloc-simple/alloc.c 2010-06-09 08:19:33.000000000 -0500
+++ b/libc/stdlib/malloc-simple/alloc.c 2010-06-09 08:40:00.000000000 -0500
@@ -61,14 +61,14 @@ void * calloc(size_t nmemb, size_t lsize
return NULL;
}
result=malloc(size);
-#if 0
- /* Standard unix mmap using /dev/zero clears memory so calloc
- * doesn't need to actually zero anything....
- */
+
+#ifndef __ARCH_USE_MMU__
+ /* mmap'd with MAP_UNINITIALIZE, we have to blank memory ourselves */
if (result != NULL) {
memset(result, 0, size);
}
#endif
+
return result;
}
#endif
More information about the uClibc
mailing list