Boost logo

Boost :

From: Daryle Walker (darylew_at_[hidden])
Date: 2005-12-22 22:05:34


On 12/22/05 10:45 AM, "Gennadiy Rozental" <gennadiy.rozental_at_[hidden]>
wrote:

[Markus Schöpflin <markus.schoepflin_at_[hidden]> wrote:]
[SNIP]
>> This ignores the fact the std::malloc() is allowed to return either 0 or some
>> unique pointer on zero sized requests, whereas a C++ allocation function
>> _must_ return a unique pointer for each zero sized request.
>>
>> If I'm correct, this could be easily fixed by changing all occurences of "p =
>> std::malloc(n)" to "p = std::malloc(n ? n : 1)" or something similar.
>
> Ok. Applied.

Shouldn't it be applied only if std::malloc returns NULL on 0-sized
allocations? A std::malloc implementation that returns unique pointers for
zero sizes is OK. Maybe something like:

    void * p = std::malloc( n );
    if ( !n && !p ) p = std::malloc( 1 );
    return p;

would be better?

-- 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT hotmail DOT com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk