realloc() (was: Re: Safe coding practices)
Applied Magnetics
3003jalp at ucsbuxa.ucsb.edu
Thu Jan 31 09:53:26 AEST 1991
In article <1991Jan30.201955.21797 at ux1.cso.uiuc.edu> mcdonald at 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.
More information about the Comp.lang.c
mailing list