remove the shared object stubs of libnsl and libresolv - let the compiler use the...
[openwrt/staging/yousong.git] / toolchain / uClibc / patches-0.9.31 / 000-upstream-calloc_return_zeroed_memory.patch
1 From afd7606ca42a2586b8823c7bd1a4a7cfd2476e3b Mon Sep 17 00:00:00 2001
2 From: Steven J. Magnani <steve@digidescorp.com>
3 Date: Wed, 09 Jun 2010 14:02:21 +0000
4 Subject: malloc-simple: Make calloc() return zeroed memory
5
6 The 0.9.31 release included a change to malloc-simple to request
7 uninitialized memory from noMMU kernels. Unfortunately, the corresponding
8 calloc() code assumed that memory returned by malloc() was already zeroed,
9 which leads to all kinds of nastiness.
10
11 Signed-off-by: Steven J. Magnani <steve@digidescorp.com>
12 Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
13 ---
14 diff --git a/libc/stdlib/malloc-simple/alloc.c b/libc/stdlib/malloc-simple/alloc.c
15 index 51da14a..914c89d 100644
16 --- a/libc/stdlib/malloc-simple/alloc.c
17 +++ b/libc/stdlib/malloc-simple/alloc.c
18 @@ -60,11 +60,10 @@ void * calloc(size_t nmemb, size_t lsize)
19 __set_errno(ENOMEM);
20 return NULL;
21 }
22 - result=malloc(size);
23 -#if 0
24 - /* Standard unix mmap using /dev/zero clears memory so calloc
25 - * doesn't need to actually zero anything....
26 - */
27 + result = malloc(size);
28 +
29 +#ifndef __ARCH_USE_MMU__
30 + /* mmap'd with MAP_UNINITIALIZE, we have to blank memory ourselves */
31 if (result != NULL) {
32 memset(result, 0, size);
33 }