[PATCH] malloc: Simplify _int_free_chunk
Rocket Ma
marocketbd@gmail.com
Thu Apr 2 06:54:15 GMT 2026
>@@ -3472,7 +3472,7 @@ __libc_realloc (void *oldmem, size_t bytes)
> size_t sz = memsize (oldp);
> memcpy (newp, oldmem, sz);
> (void) tag_region (chunk2mem (oldp), sz);
>- _int_free_chunk (ar_ptr, oldp, chunksize (oldp), 0);
>+ _int_free_chunk (ar_ptr, oldp, chunksize (oldp));
> }
> }
>
>@@ -4549,7 +4545,7 @@ _int_realloc (mstate av, mchunkptr oldp, INTERNAL_SIZE_T oldsize,
> (void) tag_region (oldmem, sz);
> newmem = tag_new_usable (newmem);
> memcpy (newmem, oldmem, sz);
>- _int_free_chunk (av, oldp, chunksize (oldp), 1);
>+ _int_free_merge_chunk (av, oldp, chunksize (oldp));
> check_inuse_chunk (av, newp);
> return newmem;
> }
Could you add some workaround to realloc to put user requested chunk
into tcache? For remainders, it's OK as user never requested. But for
some expanding scenario, the old chunk is requested by user, thus
put them into tcache may improve performance comparing to put them
in bins?
More information about the Libc-alpha
mailing list