Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2002-04-13 14:27:02 +0400
committerAlexandre Oliva <aoliva@redhat.com>2002-04-13 14:27:02 +0400
commit2f3009bd13d43a6d9894a21e5c3bd6f7eac125ac (patch)
tree15c2c1c212a439bbcda315cf70dd1e0515a32a99 /newlib/libc/stdlib
parent0cc261b11d5074e10f728381e9b25cf8c9ed4fa9 (diff)
* libc/stdlib/mallocr.c (malloc_extend_top): If correction sbrk
fails, don't bail out, and try to correct next time.
Diffstat (limited to 'newlib/libc/stdlib')
-rw-r--r--newlib/libc/stdlib/mallocr.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/newlib/libc/stdlib/mallocr.c b/newlib/libc/stdlib/mallocr.c
index 1e7120ab3..91370056e 100644
--- a/newlib/libc/stdlib/mallocr.c
+++ b/newlib/libc/stdlib/mallocr.c
@@ -2128,6 +2128,7 @@ static void malloc_extend_top(RARG nb) RDECL INTERNAL_SIZE_T nb;
char* brk; /* return value from sbrk */
INTERNAL_SIZE_T front_misalign; /* unusable bytes at front of sbrked space */
INTERNAL_SIZE_T correction; /* bytes for 2nd sbrk call */
+ int correction_failed = 0; /* whether we should relax the assertion */
char* new_brk; /* return of 2nd sbrk call */
INTERNAL_SIZE_T top_size; /* new size of top chunk */
@@ -2152,11 +2153,13 @@ static void malloc_extend_top(RARG nb) RDECL INTERNAL_SIZE_T nb;
/* Fail if sbrk failed or if a foreign sbrk call killed our space */
if (brk == (char*)(MORECORE_FAILURE) ||
(brk < old_end && old_top != initial_top))
- return;
+ return;
sbrked_mem += sbrk_size;
- if (brk == old_end) /* can just add bytes to current top */
+ if (brk == old_end /* can just add bytes to current top, unless
+ previous correction failed */
+ && ((POINTER_UINT)old_end & (pagesz - 1)) == 0)
{
top_size = sbrk_size + old_top_size;
set_head(top, top_size | PREV_INUSE);
@@ -2183,7 +2186,12 @@ static void malloc_extend_top(RARG nb) RDECL INTERNAL_SIZE_T nb;
/* Allocate correction */
new_brk = (char*)(MORECORE (correction));
- if (new_brk == (char*)(MORECORE_FAILURE)) return;
+ if (new_brk == (char*)(MORECORE_FAILURE))
+ {
+ correction = 0;
+ correction_failed = 1;
+ new_brk = brk;
+ }
sbrked_mem += correction;
@@ -2228,7 +2236,8 @@ static void malloc_extend_top(RARG nb) RDECL INTERNAL_SIZE_T nb;
#endif
/* We always land on a page boundary */
- assert(((unsigned long)((char*)top + top_size) & (pagesz - 1)) == 0);
+ assert(((unsigned long)((char*)top + top_size) & (pagesz - 1)) == 0
+ || correction_failed);
}
#endif /* DEFINE_MALLOC */