From de790bdc2785ee36730563982afc45480f6c0f42 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 8 Nov 2013 20:39:50 +0900 Subject: allow irep to be GCed --- src/proc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/proc.c') diff --git a/src/proc.c b/src/proc.c index a7e4192aa..cfb677f0a 100644 --- a/src/proc.c +++ b/src/proc.c @@ -22,6 +22,7 @@ mrb_proc_new(mrb_state *mrb, mrb_irep *irep) p->target_class = (mrb->c->ci) ? mrb->c->ci->target_class : 0; p->body.irep = irep; p->env = 0; + mrb_irep_incref(mrb, irep); return p; } @@ -80,6 +81,9 @@ mrb_proc_copy(struct RProc *a, struct RProc *b) { a->flags = b->flags; a->body = b->body; + if (!MRB_PROC_CFUNC_P(a)) { + a->body.irep->refcnt++; + }; a->target_class = b->target_class; a->env = b->env; } @@ -181,7 +185,7 @@ void mrb_init_proc(mrb_state *mrb) { struct RProc *m; - mrb_irep *call_irep = (mrb_irep *)mrb_alloca(mrb, sizeof(mrb_irep)); + mrb_irep *call_irep = (mrb_irep *)mrb_malloc(mrb, sizeof(mrb_irep)); static const mrb_irep mrb_irep_zero = { 0 }; if (call_irep == NULL) -- cgit v1.2.3