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 Dec 12, 2014
1 parent a54dc00 commit 3301868
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 3301868

Please sign in to comment.