[PATCH] malloc: replace _int_free by _int_free_chunk in sysmalloc.

Cupertino Miranda cupertino.miranda@oracle.com
Wed Dec 11 14:03:04 GMT 2024


Hi everyone, Wilco,

As previously suggested, I have isolated this patch from the tcache
improvements series.

Looking forward for your review.

Cheers,
Cupertino

sysmalloc calls to _int_free should not allow the freed chunks to be
taken by tcache. These internal calls to free do not reflect any of the
needs of the application, but rather chunk management.
This code replaces those calls to _int_free by calls to _int_free_chunk.
---
 malloc/malloc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/malloc/malloc.c b/malloc/malloc.c
index f16f89d283..6f5e875f65 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -2646,7 +2646,7 @@ sysmalloc (INTERNAL_SIZE_T nb, mstate av)
 			CHUNK_HDR_SZ | PREV_INUSE);
               set_foot (chunk_at_offset (old_top, old_size), CHUNK_HDR_SZ);
               set_head (old_top, old_size | PREV_INUSE | NON_MAIN_ARENA);
-              _int_free (av, old_top, 1);
+	      _int_free_chunk (av, old_top, chunksize (old_top), 1);
             }
           else
             {
@@ -2912,7 +2912,7 @@ sysmalloc (INTERNAL_SIZE_T nb, mstate av)
                       /* If possible, release the rest. */
                       if (old_size >= MINSIZE)
                         {
-                          _int_free (av, old_top, 1);
+			  _int_free_chunk (av, old_top, chunksize (old_top), 1);
                         }
                     }
                 }
-- 
2.39.5



More information about the Libc-alpha mailing list