This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
malloc accounting fix
- From: wmglo at dent dot med dot uni-muenchen dot de
- To: libc-alpha at sources dot redhat dot com
- Date: 8 Sep 2003 16:20:21 -0000
- Subject: malloc accounting fix
Hi,
This is a patch in response to a recent bug report on bug-glibc.
The second hunk is just to keep in sync with ptmalloc2.
Regards,
Wolfram.
2003-09-08 Wolfram Gloger <wg@malloc.de>
* malloc/malloc.c (sYSMALLOc): Move foreign sbrk accounting into
contiguous case. Bug report from Prem Gopalan
<prem@mazunetworks.com>.
(mALLOPt): Avoid requirement of C99.
Index: malloc/malloc.c
===================================================================
RCS file: /cvs/glibc/libc/malloc/malloc.c,v
retrieving revision 1.113
diff -u -r1.113 malloc.c
--- malloc/malloc.c 19 Aug 2003 16:56:07 -0000 1.113
+++ malloc/malloc.c 8 Sep 2003 16:09:28 -0000
@@ -2969,9 +2969,6 @@
*/
else {
- /* Count foreign sbrk as system_mem. */
- if (old_size)
- av->system_mem += brk - old_end;
front_misalign = 0;
end_misalign = 0;
correction = 0;
@@ -2980,6 +2977,10 @@
/* handle contiguous cases */
if (contiguous(av)) {
+ /* Count foreign sbrk as system_mem. */
+ if (old_size)
+ av->system_mem += brk - old_end;
+
/* Guarantee alignment of first new chunk made from this space */
front_misalign = (INTERNAL_SIZE_T)chunk2mem(brk) & MALLOC_ALIGN_MASK;
@@ -5164,11 +5165,11 @@
int mALLOPt(param_number, value) int param_number; int value;
#endif
{
- if(__malloc_initialized < 0)
- ptmalloc_init ();
mstate av = &main_arena;
int res = 1;
+ if(__malloc_initialized < 0)
+ ptmalloc_init ();
(void)mutex_lock(&av->mutex);
/* Ensure initialization/consolidation */
malloc_consolidate(av);