Cut off mrb_irep_free from mrb_close; based on a patch from @matsumoto-r; close #951

parent 9e8f254f
......@@ -207,6 +207,7 @@ mrb_value mrb_str_new2(mrb_state *mrb, const char *p);
mrb_state* mrb_open(void);
mrb_state* mrb_open_allocf(mrb_allocf, void *ud);
void mrb_irep_free(mrb_state*, struct mrb_irep*);
void mrb_close(mrb_state*);
int mrb_checkstack(mrb_state*,int);
......
......@@ -82,6 +82,17 @@ mrb_open(void)
void mrb_free_symtbl(mrb_state *mrb);
void mrb_free_heap(mrb_state *mrb);
void
mrb_irep_free(mrb_state *mrb, struct mrb_irep *irep)
{
if (!(irep->flags & MRB_ISEQ_NO_FREE))
mrb_free(mrb, irep->iseq);
mrb_free(mrb, irep->pool);
mrb_free(mrb, irep->syms);
mrb_free(mrb, irep->lines);
mrb_free(mrb, irep);
}
void
mrb_close(mrb_state *mrb)
{
......@@ -94,12 +105,7 @@ mrb_close(mrb_state *mrb)
mrb_free(mrb, mrb->stbase);
mrb_free(mrb, mrb->cibase);
for (i=0; i<mrb->irep_len; i++) {
if (!(mrb->irep[i]->flags & MRB_ISEQ_NO_FREE))
mrb_free(mrb, mrb->irep[i]->iseq);
mrb_free(mrb, mrb->irep[i]->pool);
mrb_free(mrb, mrb->irep[i]->syms);
mrb_free(mrb, mrb->irep[i]->lines);
mrb_free(mrb, mrb->irep[i]);
mrb_irep_free(mrb, mrb->irep[i]);
}
mrb_free(mrb, mrb->irep);
mrb_free(mrb, mrb->rescue);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment