* 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
This commit is contained in:
akr 2008-06-06 06:05:44 +00:00
parent 8471463a4a
commit f6ec71fc4c
2 changed files with 9 additions and 4 deletions

View File

@ -1,3 +1,7 @@
Fri Jun 6 15:05:02 2008 Tanaka Akira <akr@fsij.org>
* gc.c (count_objects): clear hash after counting objects.
Fri Jun 6 00:05:33 2008 Tanaka Akira <akr@fsij.org> Fri Jun 6 00:05:33 2008 Tanaka Akira <akr@fsij.org>
* lib/time.rb (Time.xmlschema): don't use float. fix * lib/time.rb (Time.xmlschema): don't use float. fix

9
gc.c
View File

@ -2294,9 +2294,6 @@ count_objects(int argc, VALUE *argv, VALUE os)
if (rb_scan_args(argc, argv, "01", &hash) == 1) { if (rb_scan_args(argc, argv, "01", &hash) == 1) {
if (TYPE(hash) != T_HASH) if (TYPE(hash) != T_HASH)
rb_raise(rb_eTypeError, "non-hash given"); 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++) { for (i = 0; i <= T_MASK; i++) {
@ -2318,8 +2315,12 @@ count_objects(int argc, VALUE *argv, VALUE os)
total += heaps[i].limit; total += heaps[i].limit;
} }
if (hash == Qnil) if (hash == Qnil) {
hash = rb_hash_new(); 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("TOTAL")), SIZET2NUM(total));
rb_hash_aset(hash, ID2SYM(rb_intern("FREE")), SIZET2NUM(freed)); rb_hash_aset(hash, ID2SYM(rb_intern("FREE")), SIZET2NUM(freed));
for (i = 0; i <= T_MASK; i++) { for (i = 0; i <= T_MASK; i++) {