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

Idan Arye via Digitalmars-d digitalmars-d at puremagic.com
Sun May 17 05:27:55 PDT 2015


On Sunday, 17 May 2015 at 12:09:37 UTC, Timon Gehr wrote:
> On 05/17/2015 10:35 AM, Idan Arye wrote:
>> ...
>>
>> How about defining `alloc.allocate(0)` to *be* an error?
>
> What is bad about allocate(0)?

It's not that allocating 0 bytes is wrong by itself(at first 
glance it seemed very wrong to me, but then I remembered that you 
are never allowed to read-from or writ-to it more than 0 bytes), 
but it's how limited it's usefulness is compared to all the 
special-casing it requires, it might be better to simply disallow 
it.


More information about the Digitalmars-d mailing list