[PATCH] malloc: Remove use of __curbrk

Wilco Dijkstra Wilco.Dijkstra@arm.com
Mon Aug 4 12:56:22 GMT 2025


Remove an odd use of __curbrk and use MORECORE (0) instead.
This fixes Hurd build since it doesn't define this symbol.

Regress passes, OK for commit?

---

diff --git a/malloc/malloc.c b/malloc/malloc.c
index b3f5a446461b607dd9181a2107d3e8809373e310..f8480c0367713b28544d12018a92f2b48b83471d 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -2646,13 +2646,11 @@ 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 top = ALIGN_UP ((uintptr_t) __curbrk + size,
-				    mp_.thp_pagesize);
-	  size = top - (uintptr_t) __curbrk;
+	  uintptr_t lastbrk = (uintptr_t) MORECORE (0);
+	  uintptr_t top = ALIGN_UP (lastbrk + size, mp_.thp_pagesize);
+	  size = top - lastbrk;
 	}
       else
 	size = ALIGN_UP (size, GLRO(dl_pagesize));



More information about the Libc-alpha mailing list