On Sat, Jun 28, 2008 at 5:32 PM, Mark B. <[EMAIL PROTECTED]> wrote:
...
> So the difference in my case was not malloc options but different
> realloc behavior.  This lurking disaster worked until I ran it on
> OpenBSD:
>
> struct test *tp1, *tp2;
> fcn_that_reallocs(&tp1);
> tp2 = tp1
> fcn_that_reallocs(&tp1);
> fail_if(tp2->id != 1);
>
> thx for the options, running that way now here too.

Yep.  That code is nonportable, as it assumes that the realloc didn't
change the address.  While some platforms guarantee that when
shrinking the allocation, or when it was the most recent allocation,
the C, POSIX, and SUS specs don't require such behavior.


Philip Guenther

Reply via email to