A safer interface for core.stdc
H. S. Teoh via Digitalmars-d
digitalmars-d at puremagic.com
Sat Feb 7 20:22:39 PST 2015
On Sat, Feb 07, 2015 at 08:15:05PM -0800, Andrei Alexandrescu via Digitalmars-d wrote:
> 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
Ah, right. But shouldn't it be enforce instead of assert, then? :-P
T
--
In theory, software is implemented according to the design that has been
carefully worked out beforehand. In practice, design documents are
written after the fact to describe the sorry mess that has gone on
before.
More information about the Digitalmars-d
mailing list