On Tue, Aug 08, 2023 at 00:44:41 +0200, Roland Illig wrote:

> Am 07.08.2023 um 23:58 schrieb Tobias Nygren:
> > Is this sort of fix acceptable for the above cases?
> >
> > +   ptrdiff_t offset = pos - buf;
> >     new_buf = realloc(buf, buf_size);
> > -   pos = new_buf + (pos - buf);
> > +   pos = new_buf + offset;
> 
> Yes.
> 
> Instead of ptrdiff_t, I prefer to use size_t to avoid having to include
> <stddef.h>, even if that means an additional type cast at WARNS=6 level:
> 
> > +   size_t offset = (size_t)(pos - buf);

I just had a massive cognitive dissonance moment... :)


-uwe

Reply via email to