[PATCH v9] malloc: add free_sized and free_aligned_sized from C23

Paul Eggert eggert@cs.ucla.edu
Mon Oct 20 16:42:46 GMT 2025


On 2025-10-20 08:42, Justin King wrote:
> +extern void free_sized (void *__ptr, size_t __size) __THROW;

Sorry if I came in late, but wouldn't callers be a bit faster if 
stdlib.h also had something like this macro?

#define free_sized(ptr, size) ((void) (size_t) { (size) }, free (ptr))

That would avoid some jump insns and/or dynamic linking hassles, because 
calling code would go straight to ordinary 'free' rather than a call to 
a jump.

Similarly for free_aligned.

If there's some reason we don't do that, a comment explaining why would 
be helpful.


> +/* Free a block allocated by `malloc`, `realloc` or `calloc` but not

Let's not use markup-style grave accents in include files; traditional 
ordinary apostrophes are fine.


More information about the Libc-alpha mailing list