std.allocator.allocate(0) -> return null or std.allocator.allocate(1)?
deadalnix via Digitalmars-d
digitalmars-d at puremagic.com
Fri May 15 13:13:47 PDT 2015
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.
- There is no point in allocating something if 0 byte are going
to be used.
The thing we got to make sure is very clear in the spec is that
free, realloc and so on functions are able to accept null as
input.
More information about the Digitalmars-d
mailing list