summaryrefslogtreecommitdiff
path: root/tools/include
diff options
context:
space:
mode:
authorDanish Khateeb <danishkhateeb03@gmail.com>2026-09-26 10:24:13 -0500
committerThomas Weißschuh <linux@weissschuh.net>2026-09-30 21:27:03 +0200
commitb7db3ba9434cbad3d15f62500104525bfa28a304 (patch)
treebfc85b1001f6af364eb339ba99f8e6c785ae3b45 /tools/include
parentda27722051fdf0775d8c5b3e33dc21bcf605dbd4 (diff)
tools/nolibc: stop rounding malloc() sizes up to 4096 bytes
malloc() rounds the size of each mapping up to a multiple of 4096, presumably to align it to a page boundary. But the page size is not 4096 on all architectures, and mmap() and munmap() round the length up to the page size themselves. Drop the rounding. As heap->len is no longer rounded up, growing a block with realloc() now always creates a new mapping. Assisted-by: LLM Signed-off-by: Danish Khateeb <danishkhateeb03@gmail.com> Reviewed-by: Willy Tarreau <w@1wt.eu> Link: https://patch.msgid.link/20260926152414.251214-2-danishkhateeb03@gmail.com Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Diffstat (limited to 'tools/include')
-rw-r--r--tools/include/nolibc/stdlib.h2
1 files changed, 0 insertions, 2 deletions
diff --git a/tools/include/nolibc/stdlib.h b/tools/include/nolibc/stdlib.h
index 6c3c620a04cf..dc554faff22a 100644
--- a/tools/include/nolibc/stdlib.h
+++ b/tools/include/nolibc/stdlib.h
@@ -130,9 +130,7 @@ void *malloc(size_t len)
{
struct nolibc_heap *heap;
- /* Always allocate memory with size multiple of 4096. */
len = sizeof(*heap) + len;
- len = (len + 4095UL) & -4096UL;
heap = mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE,
-1, 0);
if (__builtin_expect(heap == MAP_FAILED, 0))