diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-06 06:05:44 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-06 06:05:44 +0000 |
commit | f6ec71fc4c0d149ed1682b574c06ab75f125b5b1 (patch) | |
tree | 28019c34ebfa2057eeeaea860f60b553cd21ec68 /gc.c | |
parent | 8471463a4afba2a4e19ffdb87b72002862bed333 (diff) | |
download | ruby-f6ec71fc4c0d149ed1682b574c06ab75f125b5b1.tar.gz |
* gc.c (count_objects): clear hash after counting objects.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -2294,9 +2294,6 @@ count_objects(int argc, VALUE *argv, VALUE os) if (rb_scan_args(argc, argv, "01", &hash) == 1) { if (TYPE(hash) != T_HASH) rb_raise(rb_eTypeError, "non-hash given"); - if (!RHASH_EMPTY_P(hash)) { - st_foreach(RHASH_TBL(hash), set_zero, hash); - } } for (i = 0; i <= T_MASK; i++) { @@ -2318,8 +2315,12 @@ count_objects(int argc, VALUE *argv, VALUE os) total += heaps[i].limit; } - if (hash == Qnil) + if (hash == Qnil) { hash = rb_hash_new(); + } + else if (!RHASH_EMPTY_P(hash)) { + st_foreach(RHASH_TBL(hash), set_zero, hash); + } rb_hash_aset(hash, ID2SYM(rb_intern("TOTAL")), SIZET2NUM(total)); rb_hash_aset(hash, ID2SYM(rb_intern("FREE")), SIZET2NUM(freed)); for (i = 0; i <= T_MASK; i++) { |