🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #5863

Re: realloc

#5863
From: Peter da Silva
Date: Mon, 03 Apr 1989 15:43
29 lines
1229 bytes
  [ malloc(0) -> NULL is a bug]
In article <934@atanasoff.cs.iastate.edu>, hascall@atanasoff.cs.iastate.edu (John Hascall) writes:
> And what would you have it return?   An Address?

Yes.

> ...which points to zero bytes of allocated storage?

Yes.

> And would successive malloc(0) calls return the same pointer?

No.

> (you're not using any heap with each call)

Yes you are. 4-8 bytes depending on memory model.

> And then consider doing a "free" on such a pointer.

Sure.

malloc(NULL) -> NULL is an optimisation better performed by the programmer.
-- 
Peter da Silva, Xenix Support, Ferranti International Controls Corporation.

Business: uunet.uu.net!ficc!peter, peter@ficc.uu.net, +1 713 274 5180.
Personal: ...!texbell!sugar!peter, peter@sugar.hackercorp.com.
Technical Details
Message-ID: <3662@ficc.uu.net>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!unmvax!pprg.unm.edu!hc!lll-winken!uunet!sugar!ficc!peter
References: <10170@bloom-beacon.MIT.EDU> <10032@ihlpb.ATT.COM> <934@atanasoff.cs.iastate.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!unmvax!pprg.unm.edu!hc!lll-winken!uunet!sugar!ficc!peter
From: peter@ficc.uu.net (Peter da Silva)
Newsgroups: comp.std.c,comp.lang.c
Subject: Re: realloc
Message-ID: <3662@ficc.uu.net>
Date: 3 Apr 89 15:43:12 GMT
References: <10170@bloom-beacon.MIT.EDU> <10032@ihlpb.ATT.COM> <934@atanasoff.cs.iastate.edu>
Organization: Xenix Support
Lines: 29