realloc() (was: Re: Safe coding practices)

Scott Amspoker scott at bbxsda.UUCP
Mon Feb 11 04:23:45 AEST 1991


In article <00066 at jimi.UUCP> rob at jimi.UUCP writes:
>  My understanding has always been that if realloc() fails (returns NULL),
>ALL access to the previously allocated block is gone. It makes no difference
>whether you keep the original ptr or not.
>
>  This has stuck in my head because of a particularly nasty bug due to
>assuming that the original ptr was still valid after the failure. But I can't
>seem to find an adequate reference to back up my 'understanding'.

You're not imagining things.  There was a time when that was true.  We've
also had to deal with that "feature".  As for the present, someone has 
already posted a reference stating that realloc() must preserve the 
original data if it fails.

-- 
Scott Amspoker                       | 
Basis International, Albuquerque, NM |     This space available
(505) 345-5232                       | 
unmvax.cs.unm.edu!bbx!bbxsda!scott   |



More information about the Comp.lang.c mailing list