Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!hub.ucsb.edu!ucsbuxa!3003jalp From: 3003jalp@ucsbuxa.ucsb.edu (Applied Magnetics) Newsgroups: comp.lang.c Subject: Re: realloc() (was: Re: Safe coding practices) Message-ID: <8657@hub.ucsb.edu> Date: 30 Jan 91 22:53:26 GMT References: <1991Jan30.193308.3897@athena.mit.edu> <23975:Jan2516:36:5891@kramden.acf.nyu.edu> <1991Jan30.121425.16882@unhd.unh.edu> <1991Jan30.201955.21797@ux1.cso.uiuc.edu> Sender: news@hub.ucsb.edu Lines: 19 In article <1991Jan30.201955.21797@ux1.cso.uiuc.edu> mcdonald@aries.scs.uiuc.edu (Doug McDonald) writes: > [...] . Realloc returns a pointer to the new space, or NULL if the > request cannot be satisfied, in which case *p is unchanged." > The "" indicate a quote from K&R II. Note the last sentence: it says > that *p is unchanged. *p is the CONTENTS of what p originally (and > presumably still must) point to. At last sanity prevails in principle. It may not prevail in practice: The malloc subroutine, realloc subroutine, and calloc subroutine return a NULL pointer if there is no available memory or if the memory arena has been corrupted by storing outside the bounds of a block. When this happens, the block pointed to by the Pointer parameter may be destroyed. This slightly ambiguous quote is from the aix3.1 manual. To be fair to IBM, many vendors do that. --Pierre Asselin, R&D, Applied Magnetics Corp. I speak for me.