diff options
author | Peter Zhu <peter@peterzhu.ca> | 2024-02-26 15:07:28 -0500 |
---|---|---|
committer | Peter Zhu <peter@peterzhu.ca> | 2024-03-14 08:33:30 -0400 |
commit | 83618f2cfa004accdd1514de7dcbba291aa7e831 (patch) | |
tree | 3498dff9d68b8573ae31c92f107140f674a5dc28 | |
parent | 315bde5a0f95562f58405a43456ec6715ef20d32 (diff) |
[Feature #20306] Implement ruby_free_at_exit_p
ruby_free_at_exit_p is a way for extensions to determine whether they
should free all memory at shutdown.
-rw-r--r-- | include/ruby/vm.h | 7 | ||||
-rw-r--r-- | vm.c | 6 |
2 files changed, 13 insertions, 0 deletions
diff --git a/include/ruby/vm.h b/include/ruby/vm.h index 3458c28be7..8779780952 100644 --- a/include/ruby/vm.h +++ b/include/ruby/vm.h @@ -49,6 +49,13 @@ int ruby_vm_destruct(ruby_vm_t *vm); */ void ruby_vm_at_exit(void(*func)(ruby_vm_t *)); +/** + * Returns whether the Ruby VM will free all memory at shutdown. + * + * @return true if free-at-exit is enabled, false otherwise. + */ +bool ruby_free_at_exit_p(void); + RBIMPL_SYMBOL_EXPORT_END() #endif /* RUBY_VM_H */ @@ -4443,6 +4443,12 @@ rb_ruby_debug_ptr(void) bool rb_free_at_exit = false; +bool +ruby_free_at_exit_p(void) +{ + return rb_free_at_exit; +} + /* iseq.c */ VALUE rb_insn_operand_intern(const rb_iseq_t *iseq, VALUE insn, int op_no, VALUE op, |