[musl] Re: BUG: realloc(p,0) should be consistent with malloc(0)

Alejandro Colomar alx@kernel.org
Fri Jul 4 23:31:22 GMT 2025


Hi Eric,

On Fri, Jun 20, 2025 at 01:38:14AM +0200, Alejandro Colomar wrote:
> > > 		-  POSIX.1-2001
> > 
> > This one defers to C89 anywhere that it is not explicitly documenting
> > with CX shading.
> 
> Ahh, I had thought it would defer to C99 because it's older, but I guess
> it's like POSIX.1-2024 that doesn't defer to C23.  Thanks!  Then I stand
> corrected, and glibc conforms to POSIX.1-2001.

I was reading the memccpy(3) specification in POSIX.1-2004, and found
this:

	Issue 6

		The restrict keyword is added to the memccpy() prototype
		for alignment with the ISO/IEC 9899:1999 standard.

So, Issue 6 aligned with ISO C99?  Is this exceptional, or does then
POSIX.1-2001 not defer to ISO C89?

BTW, I was trying to find out the history of memccpy(3), and why it was
introduced in 4.4BSD.  Does anyone know the history?  I find it a weird
function that doesn't have any good use case, or I don't seem to see it.
Every use case I see, such as a poor-man's strlcpy(3), seems to be prone
to off-by-one errors, or have other APIs that would be more ergonomic.
What were the original uses in 4.4BSD?


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/20250705/05f9e5ff/attachment-0001.sig>


More information about the Libc-alpha mailing list