@safe @nogc memory allocation

Dicebot via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 28 13:58:17 PDT 2014


On Wednesday, 28 May 2014 at 20:51:08 UTC, Nordlöw wrote:
>> malloc? There's no wrapper around it though, like there is for 
>> uninitializedArray.
>
> Is the fact that
>
> malloc() can't be pure when new is
>
> a limitiation in the type system?
>
> Do we need a yet another code tag for this?
>
> /Per

It is also because `malloc` can return null when out of memory 
and `new` will throw an Error. Wrapper around `malloc` that 
throws `OutOfMemoryError` on null can be considered of same 
purity class as `new`.


More information about the Digitalmars-d-learn mailing list