Add API mrb_atexit().

`mrb_final_mrbgems` will be called as mrb_state atexit function.
Maybe useful in #1844.
This commit is contained in:
take_cheeze
2014-05-08 22:19:14 +09:00
parent c071ad13a9
commit 64300b2c43
4 changed files with 34 additions and 15 deletions
+7
View File
@@ -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 <assert.h>
#define mrb_assert(p) assert(p)