From 8e5595b5eea96f9077525530750e2f5f47766dec Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 12 Dec 2015 09:00:27 +0000 Subject: [PATCH] vm.c: free tables at destruction * vm.c (ruby_vm_destruct): free loading_table and fronzen_strings tables at destruction. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/vm.c b/vm.c index b83595db36..5e8d555556 100644 --- a/vm.c +++ b/vm.c @@ -2018,6 +2018,13 @@ rb_vm_add_root_module(ID id, VALUE module) return TRUE; } +static int +free_loading_table_entry(st_data_t key, st_data_t value, st_data_t arg) +{ + xfree((char *)key); + return ST_DELETE; +} + int ruby_vm_destruct(rb_vm_t *vm) { @@ -2033,6 +2040,15 @@ ruby_vm_destruct(rb_vm_t *vm) } rb_vm_living_threads_init(vm); ruby_vm_run_at_exit_hooks(vm); + if (vm->loading_table) { + st_foreach(vm->loading_table, free_loading_table_entry, 0); + st_free_table(vm->loading_table); + vm->loading_table = 0; + } + if (vm->frozen_strings) { + st_free_table(vm->frozen_strings); + vm->frozen_strings = 0; + } rb_vm_gvl_destroy(vm); if (objspace) { rb_objspace_free(objspace);