Re: malloc size
From: CBFalconer (cbfalconer_at_yahoo.com)
Date: 01/09/05
- Next message: James Hu: "Welcome to comp.lang.c!"
- Previous message: Derrick Coetzee: "Re: Does this make any sense?"
- In reply to: Howard Hinnant: "Re: malloc size"
- Next in thread: hotadvice: "Re: malloc size"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 09 Jan 2005 21:22:05 GMT
Howard Hinnant wrote:
> CBFalconer <cbfalconer@yahoo.com> wrote:
>
... snip ...
>>
>> void *request_malloc(size_t sz, size_t *actual)
>> {
>> void *p;
>>
>> if (p = malloc(sz)) *actual = sizeof_malloc(p);
>> return p;
>> }
>>
>> and I consider any other behaviour a contortion.
>
> The proposal shows how request_malloc can be simulated with malloc,
> and also states that actual is allowed to be null, in which case
> *actual should not be written to.
>
> From your version of the request_malloc simulation, you have chosen
> 3 (implementation defined behavior for zero sized requests).
Disagree. I have choses "semantically consistent". The null
actual can be handled with:
if ((p = malloc(sz)) && actual) *actual = sizeof_malloc(p);
-- Chuck F (cbfalconer@yahoo.com) (cbfalconer@worldnet.att.net) Available for consulting/temporary embedded and systems. <http://cbfalconer.home.att.net> USE worldnet address!
- Next message: James Hu: "Welcome to comp.lang.c!"
- Previous message: Derrick Coetzee: "Re: Does this make any sense?"
- In reply to: Howard Hinnant: "Re: malloc size"
- Next in thread: hotadvice: "Re: malloc size"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|