diff options
author | Carmelo Amoroso <carmelo.amoroso@st.com> | 2007-11-20 10:09:16 +0000 |
---|---|---|
committer | Carmelo Amoroso <carmelo.amoroso@st.com> | 2007-11-20 10:09:16 +0000 |
commit | 244539cd0852bbcf8f21507d7ff866d8e7fcff18 (patch) | |
tree | 5a04e6a195814b645007e4ccecb128d8c7b31ee7 /libc/stdlib/malloc | |
parent | 1cac0350028cc4a47715f63e61379d3318b0c965 (diff) | |
download | uClibc-alpine-244539cd0852bbcf8f21507d7ff866d8e7fcff18.tar.bz2 uClibc-alpine-244539cd0852bbcf8f21507d7ff866d8e7fcff18.tar.xz |
Fix Makefile.in and synch them with trunk. Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Diffstat (limited to 'libc/stdlib/malloc')
-rw-r--r-- | libc/stdlib/malloc/heap_debug.c | 10 | ||||
-rw-r--r-- | libc/stdlib/malloc/malloc.c | 4 | ||||
-rw-r--r-- | libc/stdlib/malloc/realloc.c | 7 |
3 files changed, 14 insertions, 7 deletions
diff --git a/libc/stdlib/malloc/heap_debug.c b/libc/stdlib/malloc/heap_debug.c index 9e5b61c43..e83831d3a 100644 --- a/libc/stdlib/malloc/heap_debug.c +++ b/libc/stdlib/malloc/heap_debug.c @@ -7,7 +7,7 @@ * 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> */ @@ -15,9 +15,11 @@ #include <stdio.h> #include <stdarg.h> #include <string.h> +#include <unistd.h> libc_hidden_proto(vfprintf) libc_hidden_proto(fprintf) +libc_hidden_proto(_exit) #include "malloc.h" #include "heap.h" @@ -66,7 +68,7 @@ __heap_dump (struct heap *heap, const char *str) /* Output an error message to stderr, and exit. STR is printed with the failure message. */ -static void +static void attribute_noreturn __heap_check_failure (struct heap *heap, struct heap_free_area *fa, const char *str, char *fmt, ...) { @@ -81,13 +83,13 @@ __heap_check_failure (struct heap *heap, struct heap_free_area *fa, vfprintf (stderr, fmt, val); va_end (val); - __putc ('\n', stderr); + fprintf (stderr, "\n"); __malloc_debug_set_indent (0); __malloc_debug_printf (1, "heap dump:"); __heap_dump_freelist (heap); - __exit (22); + _exit (22); } /* Do some consistency checks on HEAP. If they fail, output an error diff --git a/libc/stdlib/malloc/malloc.c b/libc/stdlib/malloc/malloc.c index 2ec8b07da..770d7aea3 100644 --- a/libc/stdlib/malloc/malloc.c +++ b/libc/stdlib/malloc/malloc.c @@ -7,7 +7,7 @@ * 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> */ @@ -200,7 +200,7 @@ malloc (size_t size) #else /* Some programs will call malloc (0). Lets be strict and return NULL */ if (unlikely (size == 0)) - return 0; + goto oom; #endif /* Check if they are doing something dumb like malloc(-1) */ diff --git a/libc/stdlib/malloc/realloc.c b/libc/stdlib/malloc/realloc.c index 4d56565aa..ec57b874e 100644 --- a/libc/stdlib/malloc/realloc.c +++ b/libc/stdlib/malloc/realloc.c @@ -7,7 +7,7 @@ * 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> */ @@ -46,6 +46,11 @@ realloc (void *mem, size_t new_size) allocation unit (SIZE is already guaranteed to be so).*/ new_size = HEAP_ADJUST_SIZE (new_size + MALLOC_HEADER_SIZE); + if (new_size < sizeof (struct heap_free_area)) + /* Because we sometimes must use a freed block to hold a free-area node, + we must make sure that every allocated block can hold one. */ + new_size = HEAP_ADJUST_SIZE (sizeof (struct heap_free_area)); + MALLOC_DEBUG (1, "realloc: 0x%lx, %d (base = 0x%lx, total_size = %d)", (long)mem, new_size, (long)base_mem, size); |