From e5db83ec65775cae80275a7a3771bb3b7b9bb205 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 21 Oct 2010 14:56:55 +0000 Subject: * gc.c (objspace_each_objects, rb_objspace_each_objects): use struct. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- gc.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'gc.c') diff --git a/gc.c b/gc.c index 05ef077102..b2be6d2357 100644 --- a/gc.c +++ b/gc.c @@ -2514,6 +2514,13 @@ lazy_sweep_enable(void) return Qnil; } +typedef int each_obj_callback(void *, void *, size_t, void *); + +struct each_obj_args { + each_obj_callback *callback; + void *data; +}; + static VALUE objspace_each_objects(VALUE arg) { @@ -2521,7 +2528,7 @@ objspace_each_objects(VALUE arg) RVALUE *membase = 0; RVALUE *pstart, *pend; rb_objspace_t *objspace = &rb_objspace; - VALUE *args = (VALUE *)arg; + struct each_obj_args *args = (struct each_obj_args *)arg; volatile VALUE v; i = 0; @@ -2544,7 +2551,7 @@ objspace_each_objects(VALUE arg) } } if (pstart != pend) { - if ((*(int (*)(void *, void *, size_t, void *))args[0])(pstart, pend, sizeof(RVALUE), (void *)args[1])) { + if ((*args->callback)(pstart, pend, sizeof(RVALUE), args->data)) { break; } } @@ -2590,19 +2597,17 @@ objspace_each_objects(VALUE arg) * use some constant value in the iteration. */ void -rb_objspace_each_objects(int (*callback)(void *vstart, void *vend, - size_t stride, void *d), - void *data) +rb_objspace_each_objects(each_obj_callback *callback, void *data) { - VALUE args[2]; + struct each_obj_args args; rb_objspace_t *objspace = &rb_objspace; rest_sweep(objspace); objspace->flags.dont_lazy_sweep = TRUE; - args[0] = (VALUE)callback; - args[1] = (VALUE)data; - rb_ensure(objspace_each_objects, (VALUE)args, lazy_sweep_enable, Qnil); + args.callback = callback; + args.data = data; + rb_ensure(objspace_each_objects, (VALUE)&args, lazy_sweep_enable, Qnil); } struct os_each_struct { -- cgit v1.2.3