diff options
author | Ulrich Drepper <drepper@redhat.com> | 1999-09-25 06:37:46 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1999-09-25 06:37:46 +0000 |
commit | a164874646386e3bba4d0ac17e6e69033396363f (patch) | |
tree | d19a008e4f5d96a8e6c548a81840f7df058de189 /malloc | |
parent | 5892e30537dbe58bb80db1f587693b77fc1a4f06 (diff) | |
download | glibc-a164874646386e3bba4d0ac17e6e69033396363f.zip glibc-a164874646386e3bba4d0ac17e6e69033396363f.tar.gz glibc-a164874646386e3bba4d0ac17e6e69033396363f.tar.bz2 |
Update.
1999-09-24 Andreas Jaeger <aj@suse.de>
* stdio-common/tst-printf.c (main): Add a testcase for large
precision. Reported by Tymm Twillman <tymm@coe.missouri.edu>.
1999-09-24 Andreas Schwab <schwab@suse.de>
* math/bits/mathcalls.h: Fix last change. Also declare __finite.
1999-09-24 Andreas Jaeger <aj@suse.de>
* intl/finddomain.c (_nl_find_domain): Fix memory leak: Free
normalized_codeset. Reported by Belicky Zsolt <zsolt@prolan.hu>.
1999-09-23 Mark Kettenis <kettenis@gnu.org>
* sysdeps/unix/sysv/linux/Makefile [malloc] (CFLAGS-malloc.c): New
variable. Define MORECORE_CLEARS to 2.
* malloc/malloc.c (cALLOc): Correctly handle systems where sbrk
doesn't clear the contents of memory that is reallocated after
decrementing the break value first. Update comment about
MORECORE_CLEARS, explaining the meaning of the values it can be
set to.
Diffstat (limited to 'malloc')
-rw-r--r-- | malloc/malloc.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c index 98a248b..5fd2dfb 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -226,8 +226,12 @@ MORECORE_FAILURE (default: -1) The value returned upon failure of MORECORE. MORECORE_CLEARS (default 1) - True (1) if the routine mapped to MORECORE zeroes out memory (which - holds for sbrk). + The degree to which the routine mapped to MORECORE zeroes out + memory: never (0), only for newly allocated space (1) or always + (2). The distinction between (1) and (2) is necessary because on + some systems, if the application first decrements and then + increments the break value, the contents of the reallocated space + are unspecified. DEFAULT_TRIM_THRESHOLD DEFAULT_TOP_PAD DEFAULT_MMAP_THRESHOLD @@ -861,11 +865,15 @@ Void_t *(*__morecore)() = __default_morecore; #endif -static size_t __libc_pagesize; - #define MORECORE (*__morecore) #define MORECORE_FAILURE 0 + +#ifndef MORECORE_CLEARS #define MORECORE_CLEARS 1 +#endif + +static size_t __libc_pagesize; + #define mmap __mmap #define munmap __munmap #define mremap __mremap @@ -3596,10 +3604,16 @@ Void_t* cALLOc(n, elem_size) size_t n; size_t elem_size; if(!ar_ptr) return 0; - /* check if expand_top called, in which case don't need to clear */ + /* Check if expand_top called, in which case there may be + no need to clear. */ #if MORECORE_CLEARS oldtop = top(ar_ptr); oldtopsize = chunksize(top(ar_ptr)); +#if MORECORE_CLEARS < 2 + /* Only newly allocated memory is guaranteed to be cleared. */ + if (oldtopsize < sbrk_base + max_sbrked_mem - (char *)oldtop) + oldtopsize = (sbrk_base + max_sbrked_mem - (char *)oldtop); +#endif #endif p = chunk_alloc (ar_ptr, sz); |