about summary refs log tree commit diff
path: root/malloc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2005-09-12 09:39:03 +0000
committerJakub Jelinek <jakub@redhat.com>2005-09-12 09:39:03 +0000
commit2b0f7faea4d49b96dbd07ff86ef9abf69ea61929 (patch)
treea37939d644b76fb707a81b0008198eccdc22c309 /malloc
parent5e6e144e096c83beefb5bd50ea22da7266e72aee (diff)
downloadglibc-2b0f7faea4d49b96dbd07ff86ef9abf69ea61929.tar.gz
glibc-2b0f7faea4d49b96dbd07ff86ef9abf69ea61929.tar.xz
glibc-2b0f7faea4d49b96dbd07ff86ef9abf69ea61929.zip
* malloc.c (struct malloc_chunk): Fix comment typo.
	(public_cALLOc): For mmapped chunks and perturb_byte != 0,
	don't clear SIZE_SZ bytes more than should be cleared.
Diffstat (limited to 'malloc')
-rw-r--r--malloc/malloc.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 65be277097..64050b4266 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -1726,7 +1726,7 @@ struct malloc_chunk {
       mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
             |             User data starts here...                          .
             .                                                               .
-            .             (malloc_usable_space() bytes)                     .
+            .             (malloc_usable_size() bytes)                      .
             .                                                               |
 nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
             |             Size of chunk                                     |
@@ -3691,8 +3691,12 @@ public_cALLOc(size_t n, size_t elem_size)
 
   /* Two optional cases in which clearing not necessary */
 #if HAVE_MMAP
-  if (perturb_byte == 0 && chunk_is_mmapped(p))
-    return mem;
+  if (chunk_is_mmapped (p))
+    {
+      if (__builtin_expect (perturb_byte, 0))
+	MALLOC_ZERO (mem, sz);
+      return mem;
+    }
 #endif
 
   csz = chunksize(p);