Browse Source

rename local "brk" var so it doesnt namespace collide with the brk() function

Mike Frysinger 17 years ago
parent
commit
11578cd602
1 changed files with 18 additions and 18 deletions
  1. 18 18
      libc/stdlib/malloc-standard/malloc.c

+ 18 - 18
libc/stdlib/malloc-standard/malloc.c

@@ -349,7 +349,7 @@ static void* __malloc_alloc(size_t nb, mstate av)
     char*           old_end;        /* its end address */
     char*           old_end;        /* its end address */
 
 
     long            size;           /* arg to first MORECORE or mmap call */
     long            size;           /* arg to first MORECORE or mmap call */
-    char*           brk;            /* return value from MORECORE */
+    char*           fst_brk;        /* return value from MORECORE */
 
 
     long            correction;     /* arg to 2nd MORECORE call */
     long            correction;     /* arg to 2nd MORECORE call */
     char*           snd_brk;        /* 2nd return val */
     char*           snd_brk;        /* 2nd return val */
@@ -453,7 +453,7 @@ static void* __malloc_alloc(size_t nb, mstate av)
     old_size = chunksize(old_top);
     old_size = chunksize(old_top);
     old_end  = (char*)(chunk_at_offset(old_top, old_size));
     old_end  = (char*)(chunk_at_offset(old_top, old_size));
 
 
-    brk = snd_brk = (char*)(MORECORE_FAILURE);
+    fst_brk = snd_brk = (char*)(MORECORE_FAILURE);
 
 
     /* If not the first time through, we require old_size to
     /* If not the first time through, we require old_size to
      * be at least MINSIZE and to have prev_inuse set.  */
      * be at least MINSIZE and to have prev_inuse set.  */
@@ -499,7 +499,7 @@ static void* __malloc_alloc(size_t nb, mstate av)
        */
        */
 
 
     if (size > 0)
     if (size > 0)
-	brk = (char*)(MORECORE(size));
+	fst_brk = (char*)(MORECORE(size));
 
 
     /*
     /*
        If have mmap, try using it as a backup when MORECORE fails or
        If have mmap, try using it as a backup when MORECORE fails or
@@ -510,7 +510,7 @@ static void* __malloc_alloc(size_t nb, mstate av)
        segregated mmap region.
        segregated mmap region.
        */
        */
 
 
-    if (brk == (char*)(MORECORE_FAILURE)) {
+    if (fst_brk == (char*)(MORECORE_FAILURE)) {
 
 
 	/* Cannot merge with old top, so add its size back in */
 	/* Cannot merge with old top, so add its size back in */
 	if (contiguous(av))
 	if (contiguous(av))
@@ -523,12 +523,12 @@ static void* __malloc_alloc(size_t nb, mstate av)
 	/* Don't try if size wraps around 0 */
 	/* Don't try if size wraps around 0 */
 	if ((unsigned long)(size) > (unsigned long)(nb)) {
 	if ((unsigned long)(size) > (unsigned long)(nb)) {
 
 
-	    brk = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE));
+	    fst_brk = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE));
 
 
-	    if (brk != (char*)(MORECORE_FAILURE)) {
+	    if (fst_brk != (char*)(MORECORE_FAILURE)) {
 
 
 		/* We do not need, and cannot use, another sbrk call to find end */
 		/* We do not need, and cannot use, another sbrk call to find end */
-		snd_brk = brk + size;
+		snd_brk = fst_brk + size;
 
 
 		/* Record that we no longer have a contiguous sbrk region.
 		/* Record that we no longer have a contiguous sbrk region.
 		   After the first time mmap is used as backup, we do not
 		   After the first time mmap is used as backup, we do not
@@ -540,14 +540,14 @@ static void* __malloc_alloc(size_t nb, mstate av)
 	}
 	}
     }
     }
 
 
-    if (brk != (char*)(MORECORE_FAILURE)) {
+    if (fst_brk != (char*)(MORECORE_FAILURE)) {
 	av->sbrked_mem += size;
 	av->sbrked_mem += size;
 
 
 	/*
 	/*
 	   If MORECORE extends previous space, we can likewise extend top size.
 	   If MORECORE extends previous space, we can likewise extend top size.
 	   */
 	   */
 
 
-	if (brk == old_end && snd_brk == (char*)(MORECORE_FAILURE)) {
+	if (fst_brk == old_end && snd_brk == (char*)(MORECORE_FAILURE)) {
 	    set_head(old_top, (size + old_size) | PREV_INUSE);
 	    set_head(old_top, (size + old_size) | PREV_INUSE);
 	}
 	}
 
 
@@ -574,7 +574,7 @@ static void* __malloc_alloc(size_t nb, mstate av)
 	    front_misalign = 0;
 	    front_misalign = 0;
 	    end_misalign = 0;
 	    end_misalign = 0;
 	    correction = 0;
 	    correction = 0;
-	    aligned_brk = brk;
+	    aligned_brk = fst_brk;
 
 
 	    /*
 	    /*
 	       If MORECORE returns an address lower than we have seen before,
 	       If MORECORE returns an address lower than we have seen before,
@@ -584,7 +584,7 @@ static void* __malloc_alloc(size_t nb, mstate av)
 	       malloc or by other threads.  We cannot guarantee to detect
 	       malloc or by other threads.  We cannot guarantee to detect
 	       these in all cases, but cope with the ones we do detect.
 	       these in all cases, but cope with the ones we do detect.
 	       */
 	       */
-	    if (contiguous(av) && old_size != 0 && brk < old_end) {
+	    if (contiguous(av) && old_size != 0 && fst_brk < old_end) {
 		set_noncontiguous(av);
 		set_noncontiguous(av);
 	    }
 	    }
 
 
@@ -595,11 +595,11 @@ static void* __malloc_alloc(size_t nb, mstate av)
 		   to foreign calls) but treat them as part of our space for
 		   to foreign calls) but treat them as part of our space for
 		   stats reporting.  */
 		   stats reporting.  */
 		if (old_size != 0)
 		if (old_size != 0)
-		    av->sbrked_mem += brk - old_end;
+		    av->sbrked_mem += fst_brk - old_end;
 
 
 		/* Guarantee alignment of first new chunk made from this space */
 		/* Guarantee alignment of first new chunk made from this space */
 
 
-		front_misalign = (size_t)chunk2mem(brk) & MALLOC_ALIGN_MASK;
+		front_misalign = (size_t)chunk2mem(fst_brk) & MALLOC_ALIGN_MASK;
 		if (front_misalign > 0) {
 		if (front_misalign > 0) {
 
 
 		    /*
 		    /*
@@ -622,7 +622,7 @@ static void* __malloc_alloc(size_t nb, mstate av)
 		correction += old_size;
 		correction += old_size;
 
 
 		/* Extend the end address to hit a page boundary */
 		/* Extend the end address to hit a page boundary */
-		end_misalign = (size_t)(brk + size + correction);
+		end_misalign = (size_t)(fst_brk + size + correction);
 		correction += ((end_misalign + pagemask) & ~pagemask) - end_misalign;
 		correction += ((end_misalign + pagemask) & ~pagemask) - end_misalign;
 
 
 		assert(correction >= 0);
 		assert(correction >= 0);
@@ -636,7 +636,7 @@ static void* __malloc_alloc(size_t nb, mstate av)
 		    correction = 0;
 		    correction = 0;
 		    snd_brk = (char*)(MORECORE(0));
 		    snd_brk = (char*)(MORECORE(0));
 		}
 		}
-		else if (snd_brk < brk) {
+		else if (snd_brk < fst_brk) {
 		    /*
 		    /*
 		       If the second call gives noncontiguous space even though
 		       If the second call gives noncontiguous space even though
 		       it says it won't, the only course of action is to ignore
 		       it says it won't, the only course of action is to ignore
@@ -649,7 +649,7 @@ static void* __malloc_alloc(size_t nb, mstate av)
 		       there is no reliable way to detect a noncontiguity
 		       there is no reliable way to detect a noncontiguity
 		       producing a forward gap for the second call.
 		       producing a forward gap for the second call.
 		       */
 		       */
-		    snd_brk = brk + size;
+		    snd_brk = fst_brk + size;
 		    correction = 0;
 		    correction = 0;
 		    set_noncontiguous(av);
 		    set_noncontiguous(av);
 		}
 		}
@@ -659,12 +659,12 @@ static void* __malloc_alloc(size_t nb, mstate av)
 	    /* handle non-contiguous cases */
 	    /* handle non-contiguous cases */
 	    else {
 	    else {
 		/* MORECORE/mmap must correctly align */
 		/* MORECORE/mmap must correctly align */
-		assert(aligned_OK(chunk2mem(brk)));
+		assert(aligned_OK(chunk2mem(fst_brk)));
 
 
 		/* Find out current end of memory */
 		/* Find out current end of memory */
 		if (snd_brk == (char*)(MORECORE_FAILURE)) {
 		if (snd_brk == (char*)(MORECORE_FAILURE)) {
 		    snd_brk = (char*)(MORECORE(0));
 		    snd_brk = (char*)(MORECORE(0));
-		    av->sbrked_mem += snd_brk - brk - size;
+		    av->sbrked_mem += snd_brk - fst_brk - size;
 		}
 		}
 	    }
 	    }