🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #6111

Re: Yet more on malloc and free and the proposed Standard

#6111
From: David Adrien Tanguay
Date: Thu, 14 Dec 1989 05:56
34 lines
1980 bytes
In article <1989Dec12.234837.11020@sq.sq.com> msb@sq.com (Mark Brader) writes:
 >
 >#         void *malloc (size_t size);
 >#
 >#   The malloc function allocates space for an object whose size is
 >#   specified by size ...
  [...]
 >#  The pointer returned ... may be assigned to a pointer to any
 >#  type of object and then used to access such an object or an array
 >#  of such objects in the space allocated ...
 >
 >Notice the words "in the space allocated"!  While the words quoted in
 >4.10.3.3 do not forbid malloc() from using storage for its own internal
 >purposes, they do require that the size of the space allocated be what
 >the argument of malloc specifies.

It doesn't say that the size of the space allocated is "size", only that
the space allocated is "for an object whose size is ...",
meaning that the size of the space allocated is no smaller than "size".

 >The hypothetical implementation discussed above may be interpreted in
 >three ways, each of which violates some part of this.
 >
 >(a) The space allocated is 101 bytes, from 1345 to 1445.  This violates
 >    the "size specified" wording in 4.10.3.3.

Which is no longer violated under my interpretation above.

 >Thus the hypothetical implementation is NOT conforming, and so, this is
 >not a bug in the pANS.  Unless of course there's something that I've missed.

I don't think you've quite got it yet, but you're close.

David Tanguay
Technical Details
Message-ID: <32602@watmath.waterloo.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!watserv1!watmath!datanguay
References: <1989Dec4.193436.4613@sq.sq.com> <11742@smoke.BRL.MIL> <1989Dec12.234837.11020@sq.sq.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!watserv1!watmath!datanguay
From: datanguay@watmath.waterloo.edu (David Adrien Tanguay)
Newsgroups: comp.std.c
Subject: Re: Yet more on malloc and free and the proposed Standard
Message-ID: <32602@watmath.waterloo.edu>
Date: 14 Dec 89 05:56:49 GMT
References: <1989Dec4.193436.4613@sq.sq.com> <11742@smoke.BRL.MIL> <1989Dec12.234837.11020@sq.sq.com>
Reply-To: datanguay@watmath.waterloo.edu (David Adrien Tanguay)
Organization: Software Development Group, U. of Waterloo, Ontario
Lines: 34