A safer interface for core.stdc
H. S. Teoh via Digitalmars-d
digitalmars-d at puremagic.com
Sat Feb 7 20:00:29 PST 2015
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");
?
> return (cast(T*) p)[0 .. n];
> }
T
--
Tell me and I forget. Teach me and I remember. Involve me and I understand. -- Benjamin Franklin
More information about the Digitalmars-d
mailing list