summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-21 14:56:55 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-21 14:56:55 +0000
commite5db83ec65775cae80275a7a3771bb3b7b9bb205 (patch)
tree758825f6758cb77d65ff2d71f976022d0e2df287 /gc.c
parent48b4512f76aa3b2a7db3a1a904769d9e9cbbd58c (diff)
* 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
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c23
1 files changed, 14 insertions, 9 deletions
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 {