alx-0029r5 - Restore the traditional realloc(3) specification

Alejandro Colomar alx@kernel.org
Fri Jun 27 13:49:56 GMT 2025


Hi Martin, Florian,

On Fri, Jun 27, 2025 at 02:54:34PM +0200, Martin Uecker wrote:
> Am Freitag, dem 27.06.2025 um 10:52 +0200 schrieb Florian Weimer:
> > * Alejandro Colomar:
> ...
> 
> > 
> > From an implementation perspective, we need clarification that the
> > allocation functions (except aligned_alloc) may reduce the alignment of
> > the returned pointer to a power of two greater or equal to the requested
> > size, for allocation sizes that are less than the fundamental alignment.
> > (Some existing implementations already do this today, in violation of
> > the standard.)
> 
> There is a general rule for all allocation functions:
> 
> "The pointer returned if the allocation succeeds is suitably aligned so
> that it may be assigned to a pointer to any type of object with a fundamental
> alignment requirement and size less than or equal to the size requested."
> 
> There is some disagreement whether the "requested size" refers to the 
> size argument or the total size.  IMHO it is a reasonable interpretation 
> that it refers to the size argument, but if implementation would explict
> this this could then break programs that swap arguments (the standard
> has no symmetry, it makes clear which is which)

Okay, I'll tweak the wording to make it clear it's the total size.
That's an easy fix.


Have a lovely day!
Alex

-- 
<https://www.alejandro-colomar.es/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20250627/93e59ff7/attachment.sig>


More information about the Libc-alpha mailing list