🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #5799

Re: realloc

#5799
From: John Hascall
Date: Fri, 31 Mar 1989 20:21
17 lines
1276 bytes
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
Technical Details
Message-ID: <934@atanasoff.cs.iastate.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!sharkey!atanasoff!hascall
References: <10170@bloom-beacon.MIT.EDU> <10032@ihlpb.ATT.COM> <9974@megaron.arizona.edu> <9122@alice.UUCP>

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