I want my Memory back ;-)
bearophile
bearophileHUGS at lycos.com
Tue Jul 13 13:36:57 PDT 2010
FeepingCreature:
> On 13.07.2010 12:28, ABothe wrote:
> > So there isn't any other method than calling C's free(); or malloc
> > (); ?
>
> That's how it is.
But you can build some abstraction by yourself, for example inside a struct you can keep the pointer to a memory block in the C heap, and in the ~this() of the struct you can put the free(). Then D has to give you a way to disallow the "new" on this struct, to be sure its destructor is called when it goes out of scope (or the object it's contained into gets deallocated).
Bye,
bearophile
More information about the Digitalmars-d
mailing list