Article View: comp.std.c
Article #1205Re: calloc()
From: D'Arcy J.M. Cain
Date: Tue, 15 Sep 1992 17:30
Date: Tue, 15 Sep 1992 17:30
31 lines
2147 bytes
2147 bytes
steve@taumet.com (Steve Clamage) writes: >darcy@druid.uucp (D'Arcy J.M. Cain) writes: >>steve@taumet.com (Steve Clamage) writes: >>>That said, suppose we have a system where int and size_t are 16 bits, >>>but it is possible to allocate an object bigger than 64K. A >>But isn't size_t guaranteed to be big enough to specify any object? It >size_t is the type returned by the sizeof operator. I believe you >must be able to apply sizeof to any object you can declare. Suppose Mark Brader and I have been discussing this in email and I agree that in the case of calloc (but not malloc) a stricly conforming compiler might be able to allocate more bytes (but not elements) than can fit into a size_t. Here is an excerpt from my last message to him: >Actually 4.10.3 never comes down on one side or the other but it does say >that "Each allocation shall yield a pointer to an object disjoint from >any other object." Now of course you can't apply sizeof to the object >because you only have a pointer to the object and hence you can only get >the size of the pointer or the size of the first element. However the >discussion on sizeof does sort of imply that if you could somehow get >an identifier for the object itself that sizeof could be applied to it >and therefore size_t must be able to represent its size. And of course >if pigs had wings they might fly so I am not sure if I've proved anything >other than that I come to these strange conclusions due to too much >thought rather than too little. :-) -- D'Arcy J.M. Cain (darcy@druid.com) | D'Arcy Cain Consulting | There's no government Toronto, Ontario, Canada | like no government! +1 416 424 2871 DoD#0082 |
Technical Details
Message-ID:
<1992Sep15.173043.18556@druid.uucp>Path:
arc1-ca.pugleaf.net!sparky!uunet!utcsri!geac!r-node!druid!darcyReferences:
<1992Sep10.180542.1009@taumet.com> <1992Sep13.142340.24107@druid.uucp> <1992Sep14.175431.10043@taumet.com>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!sparky!uunet!utcsri!geac!r-node!druid!darcy From: darcy@druid.uucp (D'Arcy J.M. Cain) Subject: Re: calloc() Message-ID: <1992Sep15.173043.18556@druid.uucp> Date: Tue, 15 Sep 1992 17:30:43 GMT References: <1992Sep10.180542.1009@taumet.com> <1992Sep13.142340.24107@druid.uucp> <1992Sep14.175431.10043@taumet.com> Organization: D'Arcy Cain Consulting Lines: 31