[musl] Re: realloci(): A realloc() variant that works in-place
Thorsten Glaser
tg@mirbsd.de
Sat Nov 1 13:38:41 GMT 2025
Paul Eggert dixit:
> You're right I'm not saying that. All I'm saying is that when
> R=realloc(P,N) succeeds, you can assume that you can adjust old
> pointers into the object addressed by P by adding R-P to them. The C
> standard says this results in undefined behavior; all that we need to
> do is fix the C standard to say it's well-defined (because it is on
> practical platforms).
That won’t fix old standard versions retroactively though.
You can already do this now by casting the old pointer to
ptraddr_t (ifdef __CHERI__) / uintptr_t (else) before the
realloc and the new one afterwards for comparison and the
arithmetic.
bye,
//mirabilos
--
13:28⎜«neurodamage:#cvs» you're a handy guy to have around for systems stuff ☺
16:06⎜<Draget:#cvs> Thank god I found you =) 20:03│«bioe007:#cvs» mira2k: ty
17:14⎜<ldiain:#cvs> Thanks big help you are :-) <bioe007> mira|nwt: ty again
18:36⎜«ThunderChicken:#cvs» mirabilos FTW! 23:03⎜«mithraic:#cvs» aaah. thanks
More information about the Libc-alpha
mailing list