1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
nobu 2010-10-21 14:56:55 +00:00
parent 48b4512f76
commit e5db83ec65
2 changed files with 18 additions and 10 deletions

View file

@ -1,4 +1,7 @@
Thu Oct 21 23:52:00 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> Thu Oct 21 23:56:54 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* gc.c (objspace_each_objects, rb_objspace_each_objects): use
struct.
* gc.c (objspace_each_objects): fix return with no value. * gc.c (objspace_each_objects): fix return with no value.

23
gc.c
View file

@ -2514,6 +2514,13 @@ lazy_sweep_enable(void)
return Qnil; return Qnil;
} }
typedef int each_obj_callback(void *, void *, size_t, void *);
struct each_obj_args {
each_obj_callback *callback;
void *data;
};
static VALUE static VALUE
objspace_each_objects(VALUE arg) objspace_each_objects(VALUE arg)
{ {
@ -2521,7 +2528,7 @@ objspace_each_objects(VALUE arg)
RVALUE *membase = 0; RVALUE *membase = 0;
RVALUE *pstart, *pend; RVALUE *pstart, *pend;
rb_objspace_t *objspace = &rb_objspace; rb_objspace_t *objspace = &rb_objspace;
VALUE *args = (VALUE *)arg; struct each_obj_args *args = (struct each_obj_args *)arg;
volatile VALUE v; volatile VALUE v;
i = 0; i = 0;
@ -2544,7 +2551,7 @@ objspace_each_objects(VALUE arg)
} }
} }
if (pstart != pend) { 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; break;
} }
} }
@ -2590,19 +2597,17 @@ objspace_each_objects(VALUE arg)
* use some constant value in the iteration. * use some constant value in the iteration.
*/ */
void void
rb_objspace_each_objects(int (*callback)(void *vstart, void *vend, rb_objspace_each_objects(each_obj_callback *callback, void *data)
size_t stride, void *d),
void *data)
{ {
VALUE args[2]; struct each_obj_args args;
rb_objspace_t *objspace = &rb_objspace; rb_objspace_t *objspace = &rb_objspace;
rest_sweep(objspace); rest_sweep(objspace);
objspace->flags.dont_lazy_sweep = TRUE; objspace->flags.dont_lazy_sweep = TRUE;
args[0] = (VALUE)callback; args.callback = callback;
args[1] = (VALUE)data; args.data = data;
rb_ensure(objspace_each_objects, (VALUE)args, lazy_sweep_enable, Qnil); rb_ensure(objspace_each_objects, (VALUE)&args, lazy_sweep_enable, Qnil);
} }
struct os_each_struct { struct os_each_struct {