Finalize GC memory

Namespace rswhite4 at googlemail.com
Sun Jun 16 14:37:15 PDT 2013


It seems that does what I want. The result is the same as with 
the current 'delete' implementation.

----
void Delete(T)(ref T var) {
	static if (is(T == struct) && is(typeof(var.__dtor)))
		var.__dtor();
		
	static if (is(T : U[], U))
		core.memory.GC.free(var.ptr);
	else {
		static if (is(T : U*, U))
			core.memory.GC.free(var);
		else
			core.memory.GC.free(&var);
	}
}
----

But if I call 'destroy' before I call GC.free, it does not work 
correct.


More information about the Digitalmars-d-learn mailing list