Memory allocation purity

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Wed May 14 22:27:22 PDT 2014


On 5/14/2014 5:56 PM, Meta wrote:
> On Thursday, 15 May 2014 at 00:50:06 UTC, Walter Bright wrote:
>> On 5/14/2014 5:03 PM, Meta wrote:
>>> Allocating memory through new and malloc should always be pure, I think, because
>>> failure either returns null in malloc's case,
>>
>> malloc cannot be pure if, with the same arguments, it returns null sometimes
>> and not other times.
>>
>>
>>> or throws an error in new's case.
>>
>> A non-recoverable error.
>>   ^^^^^^^^^^^^^^^
>
> If we pretend that there's infinite memory, then malloc will never return null.

And what happens when malloc returns null?


More information about the Digitalmars-d mailing list