From 64300b2c43e040ae2cd63bd0ef72a10a54db6631 Mon Sep 17 00:00:00 2001 From: take_cheeze Date: Thu, 8 May 2014 22:19:14 +0900 Subject: Add API `mrb_atexit()`. `mrb_final_mrbgems` will be called as mrb_state atexit function. Maybe useful in #1844. --- include/mruby.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/mruby.h b/include/mruby.h index db3b06aa8..368bf1beb 100644 --- a/include/mruby.h +++ b/include/mruby.h @@ -102,6 +102,8 @@ enum gc_state { struct mrb_jmpbuf; +typedef void (*mrb_atexit_func)(struct mrb_state*); + typedef struct mrb_state { struct mrb_jmpbuf *jmp; @@ -169,6 +171,9 @@ typedef struct mrb_state { struct RClass *eStandardError_class; void *ud; /* auxiliary data */ + + mrb_atexit_func *atexit_stack; + mrb_int atexit_stack_len; } mrb_state; #if __STDC_VERSION__ >= 201112L @@ -413,6 +418,8 @@ void* mrb_pool_realloc(struct mrb_pool*, void*, size_t oldlen, size_t newlen); mrb_bool mrb_pool_can_realloc(struct mrb_pool*, void*, size_t); void* mrb_alloca(mrb_state *mrb, size_t); +void mrb_atexit(mrb_state *mrb, mrb_atexit_func func); + #ifdef MRB_DEBUG #include #define mrb_assert(p) assert(p) -- cgit v1.2.3