about summary refs log tree commit diff
path: root/malloc
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-09-08 16:33:12 +0000
committerUlrich Drepper <drepper@redhat.com>2003-09-08 16:33:12 +0000
commit0cb71e0261a96ee93428aeb43478b493a9359e9d (patch)
treed4995a4c8c68ab1c81c38efea108c881d4fb0118 /malloc
parent65b0b4192aa2fffa77c8ee8aeb3993eaf4b969ee (diff)
downloadglibc-0cb71e0261a96ee93428aeb43478b493a9359e9d.tar.gz
glibc-0cb71e0261a96ee93428aeb43478b493a9359e9d.tar.xz
glibc-0cb71e0261a96ee93428aeb43478b493a9359e9d.zip
Update.
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.
Diffstat (limited to 'malloc')
-rw-r--r--malloc/malloc.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 8cc9e454dc..6b89083880 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -2969,9 +2969,6 @@ static Void_t* sYSMALLOc(nb, av) INTERNAL_SIZE_T nb; mstate av;
     */
 
     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 @@ static Void_t* sYSMALLOc(nb, av) INTERNAL_SIZE_T nb; mstate av;
       /* 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(int param_number, int value)
 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);