summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-24 03:00:39 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-24 03:00:39 +0000
commit04c177e277cad6e3c785de00238ef48c3fbe027a (patch)
treeeb34faf5ee1d362b825f54abb9c9ca7aa272f971
parentaab12ec054ed6af47bc67abd07076a64a10222b6 (diff)
* 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'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37310 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog11
-rw-r--r--ext/objspace/objspace.c16
2 files changed, 20 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 99e2cb76e0..3b3319a0f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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 {