std.allocator.allocate(0) -> return null or std.allocator.allocate(1)?

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Fri May 15 18:38:55 PDT 2015


On 5/15/15 1:34 PM, Timon Gehr wrote:
> On 05/15/2015 10:13 PM, deadalnix wrote:
>> On Friday, 15 May 2015 at 19:49:27 UTC, Andrei Alexandrescu wrote:
>>> Well I added the rule that allocate(0) should return null, there are a
>>> few more tests but probably nothing worrisome:
>>> https://github.com/andralex/phobos/commit/f73f6ecf1b45b0fc3cffd50d375eb15eb2311220
>>>
>>>
>>>
>>> Andrei
>>
>> I do think think this is what makes sense for us:
>>   - We should throw in case of error, not return null.
>
> - Too much overhead, there might be a fall-back installed.
> - Where do you allocate the exception object?

Yeh, failed allocations are relatively frequent within the framework 
components. -- Andrei



More information about the Digitalmars-d mailing list