diff options
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | ext/objspace/objspace.c | 16 |
2 files changed, 20 insertions, 7 deletions
@@ -1,3 +1,14 @@ +Wed Oct 24 11:55:19 2012 Koichi Sasada <ko1@atdot.net> + + * ext/objspace/objspace.c (reachable_object_from_i): change data + structure of the result of reachable objects. Keys of table + contains object_id of each reachable objects. Value of table + is an object itself or an instance of InternalObjectWrapper. + To avoid duplication, we use st_table and object_id keys. + + * ext/objspace/objspace.c (type2sym): bug fix. + Should use `i' instead of `type'. + Wed Oct 24 10:33:09 2012 Koichi Sasada <ko1@atdot.net> * gc.c (garbage_collect, gc_marks): move the location of diff --git a/ext/objspace/objspace.c b/ext/objspace/objspace.c index 1fbf148ef8..41abed90f4 100644 --- a/ext/objspace/objspace.c +++ b/ext/objspace/objspace.c @@ -302,7 +302,7 @@ type2sym(int i) CASE_TYPE(T_ICLASS); CASE_TYPE(T_ZOMBIE); #undef CASE_TYPE - default: rb_bug("type2sym: unknown type (%d)", (int)type); + default: rb_bug("type2sym: unknown type (%d)", i); } return type; } @@ -684,21 +684,23 @@ static void reachable_object_from_i(VALUE obj, void *data_ptr) { struct rof_data *data = (struct rof_data *)data_ptr; + VALUE key = obj; + VALUE val = obj; if (rb_objspace_markable_object_p(obj)) { if (rb_objspace_internal_object_p(obj)) { - obj = iow_newobj(obj); - rb_ary_push(data->internals, obj); + val = iow_newobj(obj); + rb_ary_push(data->internals, val); } - st_insert(data->refs, obj, Qtrue); + st_insert(data->refs, key, val); } } static int -collect_keys(st_data_t key, st_data_t value, st_data_t data) +collect_values(st_data_t key, st_data_t value, st_data_t data) { VALUE ary = (VALUE)data; - rb_ary_push(ary, (VALUE)key); + rb_ary_push(ary, (VALUE)value); return ST_CONTINUE; } @@ -759,7 +761,7 @@ reachable_objects_from(VALUE self, VALUE obj) rb_objspace_reachable_objects_from(obj, reachable_object_from_i, &data); - st_foreach(data.refs, collect_keys, (st_data_t)ret); + st_foreach(data.refs, collect_values, (st_data_t)ret); return ret; } else { |