From 050dd10d6f8933268ed0fd211eb5bcc8ad49f678 Mon Sep 17 00:00:00 2001 From: ko1 Date: Mon, 27 May 2013 10:01:45 +0000 Subject: * ext/objspace/objspace.c: support ObjectSpace.trace_object_allocations. Read the following test to know HOWTO. This feature is a sample of RUBY_INTERNAL_EVENT. * test/objspace/test_objspace.rb: add a test. * ext/objspace/object_tracing.c: ditto. * gc.c (rb_gc_count): add. THis function returns GC count. * internal.h: add decl. of rb_gc_count(). Same as `GC.count'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- gc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'gc.c') diff --git a/gc.c b/gc.c index c405110ebf..b06b988eab 100644 --- a/gc.c +++ b/gc.c @@ -3946,6 +3946,12 @@ gc_count_add_each_types(VALUE hash, const char *name, const size_t *types) } #endif +size_t +rb_gc_count(void) +{ + return rb_objspace.count; +} + /* * call-seq: * GC.count -> Integer @@ -3959,7 +3965,7 @@ gc_count_add_each_types(VALUE hash, const char *name, const size_t *types) static VALUE gc_count(VALUE self) { - return UINT2NUM(rb_objspace.count); + return SIZET2NUM(rb_gc_count()); } /* -- cgit v1.2.3