]> git.ipfire.org Git - thirdparty/glibc.git/commit
malloc: Cleanup macros, asserts and sysmalloc_mmap_fallback
authorWilliam Hunt <william.hunt@arm.com>
Fri, 3 Oct 2025 16:27:35 +0000 (16:27 +0000)
committerWilco Dijkstra <wilco.dijkstra@arm.com>
Fri, 3 Oct 2025 16:34:10 +0000 (16:34 +0000)
commit849a2745311ca9ee7a8f30fa0ed17a6c10bbf395
tree6e0c878cc8c1d5f5f52935ef134d93b3b827f268
parent6d9e11057708f52c77d81bf13054ce242dea5c78
malloc: Cleanup macros, asserts and sysmalloc_mmap_fallback

Refactor malloc.c to remove dead code, create macros to abstract duplicated
code, and cleanup sysmalloc_mmap_fallback to remove logic not related to the
mmap call.

Change the return type of mmap_base to uintptr_t since this allows using
operations on the return value, and avoids casting in both calls in
mremap_chunk and munmap_chunk.

Cleanup sysmalloc_mmap_fallback. Remove unused parameters nb, oldsize
and av. Remove redundant overflow check and instead use size_t for all
parameters except extra_flags to prevent overflows. Move logic not concerned
with the mmap call itself outside the function after both calls to
sysmalloc_mmap_fallback are made; this means move code for naming the VMA
and marking the arena being extended as non-contiguous to the calling code to
be handled in the case that the mmap is successful. Calculate the fallback
size from nb to avoid modifying size after it has been set for MORECORE.

Remove unused noncontiguous macro.

Remove redundant assert for checking unreachable option for global_max_fast.

Reviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>
malloc/malloc-check.c
malloc/malloc.c