Skip to content

Commit

Permalink
Switched to allocating memory from the GC heap instead of the unmanag…
Browse files Browse the repository at this point in the history
…ed heap when creating a command.
  • Loading branch information
Gary Willoughby committed May 13, 2014
1 parent 1c4707e commit d77ff86
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions source/tkd/element/element.d
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module tkd.element.element;
/**
* Imports.
*/
import core.stdc.stdlib : malloc, free;
import core.memory;
import std.array;
import std.conv;
import std.digest.crc;
Expand Down Expand Up @@ -222,10 +222,12 @@ abstract class Element

Tcl_CmdDeleteProc deleteCallbackHandler = function(ClientData data)
{
free(data);
GC.removeRoot(data);
GC.free(data);
};

CommandArgs* args = cast(CommandArgs*)malloc(CommandArgs.sizeof);
CommandArgs* args = cast(CommandArgs*)GC.malloc(CommandArgs.sizeof, GC.BlkAttr.NO_MOVE | GC.BlkAttr.NO_SCAN);
GC.addRoot(args);

(*args) = CommandArgs.init;
(*args).element = this;
Expand Down

0 comments on commit d77ff86

Please sign in to comment.