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

Alejandro Colomar alx@kernel.org
Sat Jul 5 01:45:23 GMT 2025


Hi Collin,

On Sat, Jul 05, 2025 at 02:44:02AM +0200, Alejandro Colomar wrote:
> > You can look for yourself here, <https://www.tuhs.org/cgi-bin/utree.pl>.

Hmmm, I've only found definitions, but no uses at all.  All definitions
seem to be there for compatibility with SysV.  I wonder what SysV had
this API for.  I guess it was for some networking code, as the function
seems to be for copying part of a string until a delimiter, and
appending a terminator after it (but including it in the new string).
Something like:

	char  uri[] = "https://www.example.es";
	char  scheme[countof(uri)];

	p = memccpy(scheme, uri, ':', countof(uri));
	if (p == NULL)
		goto hell;
	p = '\0';

	// Here, scheme is "https:"

This would make sense, although it would be interesting to see the exact
use case they had for it.  I'm pretty certain it was not the use case
that was envisioned by the C Committee when they standardized it in C23.


Cheers,
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/2317433e/attachment.sig>


More information about the Libc-alpha mailing list