Xref: utzoo comp.std.c:978 comp.lang.c:17332 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!sharkey!atanasoff!hascall From: hascall@atanasoff.cs.iastate.edu (John Hascall) Newsgroups: comp.std.c,comp.lang.c Subject: Re: realloc Message-ID: <934@atanasoff.cs.iastate.edu> Date: 31 Mar 89 20:21:27 GMT References: <10170@bloom-beacon.MIT.EDU> <10032@ihlpb.ATT.COM> <9974@megaron.arizona.edu> <9122@alice.UUCP> Reply-To: hascall@atanasoff.cs.iastate.edu (John Hascall) Organization: Iowa State Univ. Computation Center Lines: 17 In article <9122@alice.UUCP> andrew@alice.UUCP (Andrew Hume) writes: >gregg townsend reminds us of the pANS ``feature'' that malloc(0) returns NULL. >can anyone provide the (or any) justification of this pointless stupid >definition? i just love the idea that an initialised pointer is SOMETIMES >indistinguishable from an uninitialised pointer. And what would you have it return? An Address? ...which points to zero bytes of allocated storage? And would successive malloc(0) calls return the same pointer? (you're not using any heap with each call) And then consider doing a "free" on such a pointer. Just think of malloc(NULL) as not initialising the pointer, just as malloc(MORE_BYTES_THAN_WE_GOT) doesn't. John Hascall