Lots more work on eng::malloc

This commit is contained in:
2022-02-28 21:57:54 -05:00
parent ff932dba10
commit 7cd8eb0a43
25 changed files with 314 additions and 253 deletions

View File

@@ -4286,10 +4286,9 @@ static int sys_trim(mstate m, size_t pad) {
if (HAVE_MMAP &&
sp->size >= extra &&
!has_segment_link(m, sp)) { /* can't shrink if pinned */
size_t newsize = sp->size - extra;
/* Prefer mremap, fall back to munmap */
if ((CALL_MREMAP(sp->base, sp->size, newsize, 0) != MFAIL) ||
(CALL_MUNMAP(sp->base + newsize, extra) == 0)) {
if ((CALL_MREMAP(sp->base, sp->size, (sp->size - extra), 0) != MFAIL) ||
(CALL_MUNMAP(sp->base + (sp->size - extra), extra) == 0)) {
released = extra;
}
}