[PATCH] malloc: add free_sized and free_aligned_sized from C23

Florian Weimer fweimer@redhat.com
Wed Jun 18 15:55:52 GMT 2025


* Justin King:

> +@deftypefun void free_aligned_sized (void *@var{ptr}, size_t @var{alignment}, size_t @var{size})
> +@standards{???, stdlib.h}
> +@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{} @acsfd{} @acsmem{}}}
> +The @code{free_aligned_sized} function deallocates the block of memory pointed at by @var{ptr} that
> +was previously allocated by @code{aligned_alloc}. The size @var{size} and alignment @var{alignment}
> +must match the previously requested total size and alignment provided to @code{aligned_alloc}. Attempting
> +to deallocated memory allocated by @code{malloc}, @code{calloc} or @code{realloc} is undefined behavior.

(These lines a re little bit long.)

Should we exclude memalign etc. as well?

Overall the patch looks okay to me.  The symbols are weak, so static
linking against applications which define their own free_sized symbol
still works.  Nothing calls these functions inside glibc, so there are
no linknamespace problems.

Thanks,
Florian



More information about the Libc-alpha mailing list