Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
TypeInfo_Struct.destroy needed to check if the pointer is owned by th…
Browse files Browse the repository at this point in the history
…e GC, and if so, have the GC run it's finalizers rather than calling the finalizer directly.
  • Loading branch information
Orvid committed Jan 13, 2015
1 parent 5b070f6 commit 3c83c5c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/object_.d
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,16 @@ class TypeInfo_Struct : TypeInfo
override void destroy(void* p) const
{
if (xdtor)
(*xdtor)(p);
{
import core.memory : GC;

auto inf = GC.query(p);

if (inf != GC.BlkInfo.init && (inf.attr & GC.BlkAttr.FINALIZE))
GC.runFinalizers(p[0..1]);
else
(*xdtor)(p);
}
}

override void postblit(void* p) const
Expand Down

0 comments on commit 3c83c5c

Please sign in to comment.