Re: malloc size

From: CBFalconer (cbfalconer_at_yahoo.com)
Date: 01/09/05


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!


Relevant Pages

  • Re: Diary of a Tumor
    ... Araik Margarian wrote: ... >> For the patient, simulation 'seems' to take hours, but in fact its much ... Normal treatment would be about 15min, ...
    (sci.med.diseases.cancer)
  • Re: Another discrepancy (LTspice/switchcad3)
    ... the "design" you have will not work. ... you will see the same waveforms ... >as in the simulation until the MOSFET dies due to being ...
    (sci.electronics.cad)
  • Re: Exploiting limitations of Turing machines in Turing tests?
    ... But of course, this is just speculation, ... if someone manages to do such a simulation in future with some ... hypersupercomputer and new kinds of algorithms, ...
    (comp.ai.philosophy)
  • Re: |[4E] - Yet another 4E review
    ... Justin Fang wrote: ... |be added to the table if we actually did this 'simulation' is, ...
    (rec.games.frp.dnd)
  • Re: Games and Playing Styles
    ... The main way in which Monopoly is a simulation of property trading is most people end up getting screwed... ... the whole point of the original Landlord's Game on which it was based was to show exactly that!) ...
    (rec.games.board)