A safer interface for core.stdc

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Sat Feb 7 20:15:05 PST 2015


On 2/7/15 8:00 PM, H. S. Teoh via Digitalmars-d wrote:
> On Sat, Feb 07, 2015 at 06:19:19PM -0800, Andrei Alexandrescu via Digitalmars-d wrote:
> [...]
>> private @system T[] mallocUninitializedArrayImpl(T)(size_t n)
>> {
>>      auto p = malloc(n * T.sizeof);
>>      p || assert(0, "Not enough memory");
>
> This is a truly strange way of writing it... why not:
>
> 	assert(p !is null, "Not enough memory");
>
> ?

assert(0) is not removed in release mode. -- Andrei



More information about the Digitalmars-d mailing list