Finalize GC memory
Namespace
rswhite4 at googlemail.com
Tue Jun 18 01:52:43 PDT 2013
Here my new version:
----
void Delete(T)(ref T var) if (isAssignable!(T, typeof(null)) &&
!isStaticArray!T) {
const bool isPtr = is(T : U*, U);
static if (isPtr && (is(U == struct) || is(U == class)))
.destroy(*var);
static if (is(T : U[], U))
GC.free(var.ptr);
else {
static if (isPtr)
GC.free(var);
else
GC.free(&var);
}
var = null;
}
----
That should fulfill all wishes. :)
More information about the Digitalmars-d-learn
mailing list