mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
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:
+22
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user