🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3093

Re: What does malloc(0) return?

#3093
From: Phil Howard KA9WGN
Date: Fri, 31 May 1991 20:49
20 lines
1355 bytes
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!!  /
 \***************************************************************************/
Technical Details
Message-ID: <1991May31.204954.5255@ux1.cso.uiuc.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!convex!linac!att!news.cs.indiana.edu!ux1.cso.uiuc.edu!phil
References: <11614@ncar.ucar.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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