diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/state.c | 8 | ||||
| -rw-r--r-- | src/variable.c | 12 |
2 files changed, 14 insertions, 6 deletions
diff --git a/src/state.c b/src/state.c index c0a9c14c2..3e82a159d 100644 --- a/src/state.c +++ b/src/state.c @@ -226,7 +226,9 @@ mrb_close(mrb_state *mrb) for (i = mrb->atexit_stack_len; i > 0; --i) { mrb->atexit_stack[i - 1](mrb); } +#ifndef MRB_FIXED_STATE_ATEXIT_STACK mrb_free(mrb, mrb->atexit_stack); +#endif } /* free */ @@ -268,6 +270,11 @@ mrb_top_self(mrb_state *mrb) void mrb_state_atexit(mrb_state *mrb, mrb_atexit_func f) { +#ifdef MRB_FIXED_STATE_ATEXIT_STACK + if (mrb->atexit_stack_len + 1 > MRB_FIXED_STATE_ATEXIT_STACK_SIZE) { + mrb_raise(mrb, E_RUNTIME_ERROR, "exceeded fixed state atexit stack limit"); + } +#else size_t stack_size; stack_size = sizeof(mrb_atexit_func) * (mrb->atexit_stack_len + 1); @@ -276,6 +283,7 @@ mrb_state_atexit(mrb_state *mrb, mrb_atexit_func f) } else { mrb->atexit_stack = (mrb_atexit_func*)mrb_realloc(mrb, mrb->atexit_stack, stack_size); } +#endif mrb->atexit_stack[mrb->atexit_stack_len++] = f; } diff --git a/src/variable.c b/src/variable.c index 5f762dd0b..74bb591cf 100644 --- a/src/variable.c +++ b/src/variable.c @@ -124,10 +124,10 @@ iv_put(mrb_state *mrb, iv_tbl *t, mrb_sym sym, mrb_value val) * mrb * t the variable table to be searched. * sym the symbol to be used as the key. - * vp the value pointer. Recieves the value if the specified symbol contains - * in the instance variable table. + * vp the value pointer. Receives the value if the specified symbol is + * contained in the instance variable table. * Returns - * true if the specfiyed symbol contains in the instance variable table. + * true if the specified symbol is contained in the instance variable table. */ static mrb_bool iv_get(mrb_state *mrb, iv_tbl *t, mrb_sym sym, mrb_value *vp) @@ -159,10 +159,10 @@ iv_get(mrb_state *mrb, iv_tbl *t, mrb_sym sym, mrb_value *vp) * Parameters * t the variable table to be searched. * sym the symbol to be used as the key. - * vp the value pointer. Recieve the deleted value if the symbol contans - * in the instance varible table. + * vp the value pointer. Receive the deleted value if the symbol is + * contained in the instance variable table. * Returns - * true if the specfied symbol contains in the instance variable table. + * true if the specified symbol is contained in the instance variable table. */ static mrb_bool iv_del(mrb_state *mrb, iv_tbl *t, mrb_sym sym, mrb_value *vp) |
