realloc((char *)NULL,size) - how standard ?

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Mon Feb 25 06:11:43 AEST 1991


In article <1991Feb24.071716.409 at athena.mit.edu> scs at adam.mit.edu writes:
>      Passing an initially-null pointer to realloc can make it very easy
>      to write a self-starting incremental allocation algorithm.

I find this advice counterproductive. Much better would be

	Passing an initially null pointer to realloc may seem a tempting
	way to write a self-starting incremental allocation algorithm,
	but it is simply not portable. It's just as easy---and much more
	portable---to start by allocating one element.

---Dan



More information about the Comp.lang.c mailing list