Memory allocation purity
Steven Schveighoffer via Digitalmars-d
digitalmars-d at puremagic.com
Thu May 15 06:02:02 PDT 2014
On Wed, 14 May 2014 20:50:08 -0400, Walter Bright
<newshound2 at digitalmars.com> 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.
Basically, you are saying that malloc must return the same block whenever
it's called with the same parameters. This is simply nonsense.
null is not special, it's just another block.
I'm not saying malloc should be pure based on this, but the possibility
that it returns null does not disqualify it.
-Steve
More information about the Digitalmars-d
mailing list