| ... | ... | @@ -56,6 +56,7 @@ |
| 56 | 56 | |
| 57 | 57 | // Defind by the linker to have the address of the start of the heap. |
| 58 | 58 | extern unsigned char __heap_base; |
| 59 | extern unsigned char __heap_end __attribute__((__weak__)); |
| 59 | 60 | |
| 60 | 61 | // Behavior of right shifting a signed integer is compiler implementation defined. |
| 61 | 62 | static_assert((((int32_t)0x80000000U) >> 31) == -1, "This malloc implementation requires that right-shifting a signed integer produces a sign-extending (arithmetic) shift!"); |
| ... | ... | @@ -545,7 +546,10 @@ static bool claim_more_memory(size_t numBytes) |
| 545 | 546 | // If this is the first time we're called, see if we can use |
| 546 | 547 | // the initial heap memory set up by wasm-ld. |
| 547 | 548 | if (!listOfAllRegions) { |
| 548 | | unsigned char *heap_end = sbrk(0); |
| 549 | unsigned char *heap_end = &__heap_end; |
| 550 | if (heap_end == NULL) |
| 551 | heap_end = sbrk(0); |
| 552 | |
| 549 | 553 | if (numBytes <= (size_t)(heap_end - &__heap_base)) { |
| 550 | 554 | startPtr = &__heap_base; |
| 551 | 555 | endPtr = heap_end; |