summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-09-23 00:05:07 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-09-23 00:05:07 +0000
commitc9faac88af5744e03ad2cdcb367d5ac00f5d9eee (patch)
tree9ff3aa0d7487d0d87748fc98a4cd4adb1530b3d2 /gc.c
parent0a274820bdcfd662f4381cef5915455789077ef6 (diff)
* gc.c (os_obj_of, os_each_obj): hide objects to be finalized.
[ruby-dev:31810] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c42
1 files changed, 5 insertions, 37 deletions
diff --git a/gc.c b/gc.c
index 83eb75cb8b..2d19e7c98b 100644
--- a/gc.c
+++ b/gc.c
@@ -1692,37 +1692,6 @@ Init_heap(void)
}
static VALUE
-os_live_obj(void)
-{
- int i;
- int n = 0;
-
- for (i = 0; i < heaps_used; i++) {
- RVALUE *p, *pend;
-
- p = heaps[i].slot; pend = p + heaps[i].limit;
- for (;p < pend; p++) {
- if (p->as.basic.flags) {
- switch (TYPE(p)) {
- case T_ICLASS:
- case T_NODE:
- case T_VALUES:
- continue;
- case T_CLASS:
- if (FL_TEST(p, FL_SINGLETON)) continue;
- default:
- if (!p->as.basic.klass) continue;
- rb_yield((VALUE)p);
- n++;
- }
- }
- }
- }
-
- return INT2FIX(n);
-}
-
-static VALUE
os_obj_of(VALUE of)
{
int i;
@@ -1734,7 +1703,8 @@ os_obj_of(VALUE of)
p = heaps[i].slot; pend = p + heaps[i].limit;
for (;p < pend; p++) {
if (p->as.basic.flags) {
- switch (TYPE(p)) {
+ switch (BUILTIN_TYPE(p)) {
+ case T_NONE:
case T_ICLASS:
case T_NODE:
case T_VALUES:
@@ -1743,7 +1713,7 @@ os_obj_of(VALUE of)
if (FL_TEST(p, FL_SINGLETON)) continue;
default:
if (!p->as.basic.klass) continue;
- if (rb_obj_is_kind_of((VALUE)p, of)) {
+ if (!of || rb_obj_is_kind_of((VALUE)p, of)) {
rb_yield((VALUE)p);
n++;
}
@@ -1795,11 +1765,9 @@ os_each_obj(int argc, VALUE *argv)
rb_secure(4);
if (rb_scan_args(argc, argv, "01", &of) == 0) {
- return os_live_obj();
- }
- else {
- return os_obj_of(of);
+ of = 0;
}
+ return os_obj_of(of);
}
static VALUE finalizers;