diff --git a/ChangeLog b/ChangeLog index 9722d13fe4..81d5da3733 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,12 @@ -Wed Sep 9 11:45:58 2009 Nobuyoshi Nakada +Wed Sep 9 11:55:07 2009 Nobuyoshi Nakada * dir.c (dir_data_type): typed. * enumerator.c (enumerator_data_type): typed. (yielder_data_type, generator_data_type): ditto. + * error.c (name_err_mesg_data_type): typed. + Wed Sep 9 11:11:33 2009 Nobuyoshi Nakada * include/ruby/ruby.h (rb_data_type_struct): constified dsize. diff --git a/error.c b/error.c index aab3d66483..a7342de4e5 100644 --- a/error.c +++ b/error.c @@ -769,22 +769,40 @@ nometh_err_initialize(int argc, VALUE *argv, VALUE self) } /* :nodoc: */ +#define NAME_ERR_MESG_COUNT 3 + static void -name_err_mesg_mark(VALUE *ptr) +name_err_mesg_mark(void *p) { - rb_gc_mark_locations(ptr, ptr+3); + VALUE *ptr = p; + rb_gc_mark_locations(ptr, ptr+NAME_ERR_MESG_COUNT); } +#define name_err_mesg_free RUBY_TYPED_DEFAULT_FREE + +static size_t +name_err_mesg_memsize(const void *p) +{ + return p ? (NAME_ERR_MESG_COUNT * sizeof(VALUE)) : 0; +} + +static const rb_data_type_t name_err_mesg_data_type = { + "name_err_mesg", + name_err_mesg_mark, + name_err_mesg_free, + name_err_mesg_memsize, +}; + /* :nodoc: */ static VALUE name_err_mesg_new(VALUE obj, VALUE mesg, VALUE recv, VALUE method) { - VALUE *ptr = ALLOC_N(VALUE, 3); + VALUE *ptr = ALLOC_N(VALUE, NAME_ERR_MESG_COUNT); ptr[0] = mesg; ptr[1] = recv; ptr[2] = method; - return Data_Wrap_Struct(rb_cNameErrorMesg, name_err_mesg_mark, -1, ptr); + return TypedData_Wrap_Struct(rb_cNameErrorMesg, &name_err_mesg_data_type, ptr); } /* :nodoc: */ @@ -798,9 +816,9 @@ name_err_mesg_equal(VALUE obj1, VALUE obj2) if (rb_obj_class(obj2) != rb_cNameErrorMesg) return Qfalse; - Data_Get_Struct(obj1, VALUE, ptr1); - Data_Get_Struct(obj2, VALUE, ptr2); - for (i=0; i<3; i++) { + TypedData_Get_Struct(obj1, VALUE, &name_err_mesg_data_type, ptr1); + TypedData_Get_Struct(obj2, VALUE, &name_err_mesg_data_type, ptr2); + for (i=0; i