fix cubescript func refcount

master
Daniel Kolesa 2015-12-18 15:06:42 +01:00
parent b217bbcd65
commit cc1cfe1328
1 changed files with 7 additions and 5 deletions

12
main.cc
View File

@ -246,6 +246,11 @@ struct ObState: CsState {
cscript::bcode_ref(func);
}
~Rule() { cscript::bcode_unref(func); }
void set_func(Uint32 *c) {
func = c;
cscript::bcode_ref(func);
}
};
Vector<Rule> rules;
@ -448,10 +453,7 @@ struct ObState: CsState {
Rule &r = rules.push();
r.target = target;
r.action = action;
if (body) {
r.func = body;
cscript::bcode_ref(body);
}
r.set_func(body);
r.deps = cscript::util::list_explode(dep);
}
}
@ -465,9 +467,9 @@ struct ObState: CsState {
if (!oldr)
return;
Rule &r = rules.push();
r.set_func(oldr->func);
r.target = tgt;
r.action = oldr->action;
r.func = oldr->func;
r.deps = inherit_deps ? oldr->deps : cscript::util::list_explode(dep);
}