Merge pull request #11427 from justinweiss/free-smaller-blocks

[3DS] Free memory in 1MB blocks
This commit is contained in:
Autechre 2020-10-09 03:21:02 +02:00 committed by GitHub
commit 9ac393fa02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -141,9 +141,12 @@ void* _sbrk_r(struct _reent *ptr, ptrdiff_t incr)
__heap_size += diff;
if (diff < 0)
svcControlMemory(&tmp, __heapBase + __heap_size,
0x0, -diff, MEMOP_FREE, MEMPERM_READ | MEMPERM_WRITE);
while (diff < 0) {
int size = -diff < 0x100000 ? -diff : 0x100000;
diff += size;
svcControlMemory(&tmp, __heapBase + __heap_size - diff,
0x0, size, MEMOP_FREE, 0);
}
sbrk_top += incr;