diff --git a/main.cc b/main.cc index 04202ff..3e2fc93 100644 --- a/main.cc +++ b/main.cc @@ -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 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); }