From 7ab623afb9b2a4709c68f10debd300bfb4622d0c Mon Sep 17 00:00:00 2001 From: Wilco Dijkstra Date: Mon, 4 Aug 2025 17:31:56 +0000 Subject: [PATCH] Revert "Remove use of __curbrk." This reverts commit 1ee0b771a9c0cd2b882fe7acd38deddb7d4fbef2. --- malloc/malloc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/malloc/malloc.c b/malloc/malloc.c index 5257ee24fd..9d646abae9 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -2642,11 +2642,13 @@ sysmalloc (INTERNAL_SIZE_T nb, mstate av) previous calls. Otherwise, we correct to page-align below. */ + /* Defined in brk.c. */ + extern void *__curbrk; if (__glibc_unlikely (mp_.thp_pagesize != 0)) { - uintptr_t lastbrk = (uintptr_t) MORECORE (0); - uintptr_t top = ALIGN_UP (lastbrk + size, mp_.thp_pagesize); - size = top - lastbrk; + uintptr_t top = ALIGN_UP ((uintptr_t) __curbrk + size, + mp_.thp_pagesize); + size = top - (uintptr_t) __curbrk; } else size = ALIGN_UP (size, GLRO(dl_pagesize));