aboutsummaryrefslogtreecommitdiffstats
path: root/vm.c
diff options
context:
space:
mode:
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/vm.c b/vm.c
index a518e950cb..64081b49e5 100644
--- a/vm.c
+++ b/vm.c
@@ -468,20 +468,25 @@ rb_frame_pop(void)
void
ruby_vm_at_exit(void (*func)(rb_vm_t *))
{
- rb_ary_push((VALUE)&GET_VM()->at_exit, (VALUE)func);
+ rb_vm_t *vm = GET_VM();
+ rb_at_exit_list *nl = ALLOC(rb_at_exit_list);
+ nl->func = func;
+ nl->next = vm->at_exit;
+ vm->at_exit = nl;
}
static void
ruby_vm_run_at_exit_hooks(rb_vm_t *vm)
{
- VALUE hook = (VALUE)&vm->at_exit;
+ rb_at_exit_list *l = vm->at_exit;
- while (RARRAY_LEN(hook) > 0) {
- typedef void rb_vm_at_exit_func(rb_vm_t*);
- rb_vm_at_exit_func *func = (rb_vm_at_exit_func*)rb_ary_pop(hook);
+ while (l) {
+ rb_at_exit_list* t = l->next;
+ rb_vm_at_exit_func *func = l->func;
+ free(l);
+ l = t;
(*func)(vm);
}
- rb_ary_free(hook);
}
/* Env */
@@ -2172,8 +2177,6 @@ vm_init2(rb_vm_t *vm)
MEMZERO(vm, rb_vm_t, 1);
rb_vm_living_threads_init(vm);
vm->src_encoding_index = -1;
- vm->at_exit.basic.flags = (T_ARRAY | RARRAY_EMBED_FLAG) & ~RARRAY_EMBED_LEN_MASK; /* len set 0 */
- rb_obj_hide((VALUE)&vm->at_exit);
vm_default_params_setup(vm);
}