Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!convex!linac!att!news.cs.indiana.edu!ux1.cso.uiuc.edu!phil From: phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) Newsgroups: comp.std.c Subject: Re: What does malloc(0) return? Message-ID: <1991May31.204954.5255@ux1.cso.uiuc.edu> Date: 31 May 91 20:49:54 GMT References: <11614@ncar.ucar.edu> Distribution: na Organization: University of Illinois at Urbana Lines: 20 steve@unidata.ucar.edu (Steve Emmerson) writes: >Greetings, > >The subject-line says it all and my K&R2 is silent on the matter. >Is the answer NULL, non-NULL (but don't dereference), undefined, >or implementation-defined? If it did return the address of somewhere in memory, you cannot dereference that pointer without exceeding the size. It would be more useful if it did return something consistent like NULL. Prior to this posting, had I needed to implement malloc(0) I am sure I would have just implemented it to return NULL in that case unless I found a reason not to. -- /***************************************************************************\ / Phil Howard -- KA9WGN -- phil@ux1.cso.uiuc.edu | Guns don't aim guns at \ \ Lietuva laisva -- Brivu Latviju -- Eesti vabaks | people; CRIMINALS do!! / \***************************************************************************/