Move MRB_TRY part of mrb_close to src/error.c; ref 6cc52b3

We don't want to increase number of files that should be compiled by C++
compiler when `enable_cxx_exception` is turned on.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2021-02-03 09:41:22 +09:00
parent 6cc52b3210
commit 810d13dacd
2 changed files with 26 additions and 18 deletions
+22
View File
@@ -591,6 +591,28 @@ mrb_core_init_abort(mrb_state *mrb)
exc_throw(mrb, mrb_nil_value());
}
void
mrb_protect_atexit(mrb_state *mrb)
{
if (mrb->atexit_stack_len > 0) {
struct mrb_jmpbuf *prev_jmp = mrb->jmp;
struct mrb_jmpbuf c_jmp;
for (int i = mrb->atexit_stack_len; i > 0; --i) {
MRB_TRY(&c_jmp) {
mrb->jmp = &c_jmp;
mrb->atexit_stack[i - 1](mrb);
mrb->jmp = prev_jmp;
} MRB_CATCH(&c_jmp) {
/* ignore atexit errors */
} MRB_END_EXC(&c_jmp);
}
#ifndef MRB_FIXED_STATE_ATEXIT_STACK
mrb_free(mrb, mrb->atexit_stack);
#endif
mrb->jmp = prev_jmp;
}
}
mrb_noreturn void
mrb_raise_nomemory(mrb_state *mrb)
{