Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/state.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "mruby/irep.h"
#include "mruby/variable.h"
#include <string.h>
#include <setjmp.h>
#include <stdio.h>

void mrb_init_heap(mrb_state*);
void mrb_init_core(mrb_state*);
Expand All @@ -16,6 +18,7 @@ void mrb_final_core(mrb_state*);
mrb_state*
mrb_open_allocf(mrb_allocf f, void *ud)
{
jmp_buf c_jmp;
static const mrb_state mrb_state_zero = { 0 };
mrb_state *mrb = (mrb_state *)(f)(NULL, NULL, sizeof(mrb_state), ud);
if (mrb == NULL) return NULL;
Expand All @@ -26,7 +29,20 @@ mrb_open_allocf(mrb_allocf f, void *ud)
mrb->current_white_part = MRB_GC_WHITE_A;

mrb_init_heap(mrb);

if (setjmp(c_jmp) != 0) {
if (mrb->exc) {
#ifdef ENABLE_STDIO
mrb_p(mrb, mrb_obj_value(mrb->exc));
#endif
mrb->jmp = NULL;
}
return NULL;
}
mrb->jmp = &c_jmp;

mrb_init_core(mrb);
mrb->jmp = NULL;
return mrb;
}

Expand Down