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

Jonathan I. Kamens jik at athena.mit.edu
Thu Jan 31 06:33:08 AEST 1991


In article <1991Jan30.121425.16882 at unhd.unh.edu>, pas at unhd.unh.edu (Paul A. Sand) writes:
|> Emphasis is Jaeschke's. Even a tyro like me can recognize that you
|> are in big trouble if (a) the realloc() fails, (b) ptr is your only
|> access to the block, and (c) you had something important there.

  I believe that if the realloc() fails, the memory block pointed to by the
pointer passed into realloc() is no longer guaranteed to be valid.  Therefore,
Jaeschke is right -- after realloc() returns NULL, you should not try to use
the block whose address you passed into realloc().


-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710



More information about the Comp.lang.c mailing list