diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-11-08 20:39:50 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-11-08 20:39:50 +0900 |
| commit | de790bdc2785ee36730563982afc45480f6c0f42 (patch) | |
| tree | efc81547c8a6190a00bbd0fce704a02c8e373c3a /src/proc.c | |
| parent | cba07b02755711630e418fcf361d94cf47bb6730 (diff) | |
| download | mruby-de790bdc2785ee36730563982afc45480f6c0f42.tar.gz mruby-de790bdc2785ee36730563982afc45480f6c0f42.zip | |
allow irep to be GCed
Diffstat (limited to 'src/proc.c')
| -rw-r--r-- | src/proc.c | 6 |
1 files changed, 5 insertions, 1 deletions
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) |
