diff options
Diffstat (limited to 'src/proc.c')
| -rw-r--r-- | src/proc.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/proc.c b/src/proc.c index c8d09e62d..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,15 +185,14 @@ 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_iseq == NULL || call_irep == NULL ) + if (call_irep == NULL) return; *call_irep = mrb_irep_zero; call_irep->flags = MRB_ISEQ_NO_FREE; - call_irep->idx = -1; call_irep->iseq = call_iseq; call_irep->ilen = 1; |
