File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 4242 wrapper->raw ->{{ field.name }} = {% if not field.cType | isPointer %}*{% endif %}ObjectWrap::Unwrap<{{ field.cppClassName }}>(value->ToObject ())->GetValue ();
4343
4444 {% elsif field.isCallbackFunction %}
45+ if (wrapper->{{ field.name }} != NULL ) {
46+ delete wrapper->{{ field.name }};
47+ }
48+
4549 if (value->IsFunction ()) {
4650 if (!wrapper->raw ->{{ field.name }}) {
4751 wrapper->raw ->{{ field.name }} = ({{ field.cType }}){{ field.name }}_cppCallback;
Original file line number Diff line number Diff line change @@ -41,8 +41,19 @@ using namespace std;
4141}
4242
4343{{ cppClassName }}::~{{ cppClassName }}() {
44- // This is going to cause memory leaks. We'll have to solve that later
45- // TODO: Clean up memory better
44+ {% each fields|fieldsInfo as field %}
45+ {% if not field.ignore %}
46+ {% if not field.isEnum %}
47+ {% if field.isCallbackFunction %}
48+ if (this ->{{ field.name }} != NULL ) {
49+ delete this ->{{ field.name }};
50+ this ->raw ->{{ fields|payloadFor field.name }} = NULL ;
51+ }
52+ {% endif %}
53+ {% endif %}
54+ {% endif %}
55+ {% endeach %}
56+
4657 if (this ->selfFreeing ) {
4758 free (this ->raw );
4859 }
@@ -65,7 +76,7 @@ void {{ cppClassName }}::ConstructFields() {
6576 // the current instance
6677 this ->raw ->{{ field.name }} = NULL ;
6778 this ->raw ->{{ fields|payloadFor field.name }} = (void *)this ;
68- this ->{{ field.name }} = new NanCallback () ;
79+ this ->{{ field.name }} = NULL ;
6980 {% elsif field.payloadFor %}
7081
7182 Local<Value> {{ field.name }} = NanUndefined ();
You can’t perform that action at this time.
0 commit comments