Class deallocator not being called -- bug or oversight?
Regan Heath
regan at netmail.co.nz
Mon Sep 24 09:06:00 PDT 2007
Sean Kelly wrote:
> Oh for what it's worth, I can't figure out where Phobos is calling class
> deallocators--the block I'd expect to be used in internal/gc/gc.d is
> commented out. I don't suppose someone could test this with Phobos to
> see if it works?
Works on Windows with DMD 2.004.
import std.stdio;
import std.c.stdlib;
class A
{
new(size_t sz)
{
writefln("A new.");
void* p = malloc(sz);
return p;
}
delete(void* p)
{
writefln("A delete.");
if(p is null)
return;
free(p);
}
this()
{
writefln("A ctor.");
}
~this()
{
writefln("A dtor.");
}
}
void main()
{
A a = new A();
delete a;
}
Regan
More information about the Digitalmars-d-learn
mailing list