Charles Hixson wrote:
Main routine:
void main()
{
try
{ BlockFile bf;
bf = new BlockFile ("test.bf", 4096);
writefln ("before close");
bf.close;
bf = null;
writefln ("after close");
BlockFile cf = new BlockFile ("test.bf", 4096);
writefln ("after second open");
}
catch (Exception e)
{ writefln ("Caught Exception ", e); }
}
Results in:
Exiting BlockFile::this
before close
after close
Exiting BlockFile::this
after second open
Segmentation fault
I could post all the code. It's only 146 lines. But perhaps this is
enough?
So after the discussion I decided that it appeared to make BlockFile
into a scope class. I did, removing all destructors and delete
operations. The new main method was:
void main()
{
{ scope BlockFile bf;
bf = new BlockFile ("test.bf", 4096);
writefln ("before close");
}
{
writefln ("after close");
scope BlockFile cf = new BlockFile ("test.bf", 4096);
writefln ("after second open");
writefln ("after writefln");
}
}
Yielding:
Exiting BlockFile::this
before close
after close
Exiting BlockFile::this
after second open
after writefln
Apparently this can't be handled with garbage collection.