From 3fc848b54575b1f9ed60106365bc2223c109e2a1 Mon Sep 17 00:00:00 2001 From: dearblue Date: Sun, 10 Jan 2021 21:41:51 +0900 Subject: Replace `tempirep` with `RProc` Previously I used the `RData` object to avoid a memory leak in `mrb_irep` if `src/load.c` failed. ref: https://github.com/mruby/mruby/pull/4250 commit: f1523d24042ca3416dc5b9be7b3fc220ddaed896 Considering that the `RProc` object will be created in the subsequent process, it is preferable to create the `RProc` object from the beginning. Along with this, the inside of `read_irep()` is replaced with the processing centered on the `RProc` object. The global function that returns the `mrb_irep` pointer is still provided for compatibility. --- src/proc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/proc.c') diff --git a/src/proc.c b/src/proc.c index d58d9d0df..68ca941c3 100644 --- a/src/proc.c +++ b/src/proc.c @@ -52,7 +52,9 @@ mrb_proc_new(mrb_state *mrb, const mrb_irep *irep) p->e.target_class = tc; } p->body.irep = irep; - mrb_irep_incref(mrb, (mrb_irep*)irep); + if (irep) { + mrb_irep_incref(mrb, (mrb_irep*)irep); + } return p; } -- cgit v1.2.3