Manual memory management in D2

pillsy pillsbury at gmail.com
Tue Jul 13 16:50:00 PDT 2010


== Quote from Andrei Alexandrescu (SeeWebsiteForEmail at erdani.org)'s article
> On 07/13/2010 04:42 PM, Vladimir Panteleev wrote:
[...]
> I agree. I think we should, again, define two primitives:

> T* malloc(T, A...)(A args) if (!is(T == class) && !isDynamicArray!T);
> T malloc(T, A...)(A args) if (is(T == class) || isDynamicArray!T);
> free(T)(ref T obj);

> The first two call C's malloc, constructor (if any), and returns the
> allocated object. The last calls the destructor (if any) and then free().
> worksforyou?

I think malloc should be malloc and free should be free. I'd like almost any other conceivable pair of
names better, like make/unmake, create/destroy, build/smash, whatever.

Cheers,
Pillsy


More information about the Digitalmars-d mailing list