ext/cairo/rb_cairo_surface.c in cairo-1.17.6 vs ext/cairo/rb_cairo_surface.c in cairo-1.17.7

- old
+ new

@@ -101,10 +101,22 @@ static cairo_user_data_key_t cr_object_holder_key; static cairo_user_data_key_t cr_finished_key; #define _SELF (RVAL2CRSURFACE(self)) +static void cr_surface_free (void *ptr); +static const rb_data_type_t cr_surface_type = { + "Cairo::Surface", + { + NULL, + cr_surface_free, + }, + NULL, + NULL, + RUBY_TYPED_FREE_IMMEDIATELY, +}; + static VALUE cr_paper_parse (VALUE paper_description) { return rb_funcall (rb_cCairo_Paper, cr_id_parse, 2, paper_description, Qtrue); } @@ -238,11 +250,11 @@ cairo_surface_t *surface; if (!rb_cairo__is_kind_of (obj, rb_cCairo_Surface)) { rb_raise (rb_eTypeError, "not a cairo surface"); } - Data_Get_Struct (obj, cairo_surface_t, surface); + TypedData_Get_Struct (obj, cairo_surface_t, &cr_surface_type, surface); return surface; } cairo_surface_t * rb_cairo_surface_from_ruby_object (VALUE obj) @@ -459,11 +471,11 @@ { VALUE klass; klass = cr_surface_get_klass (surface); cairo_surface_reference (surface); rb_cairo_surface_adjust_memory_usage (surface, CR_TRUE); - return Data_Wrap_Struct (klass, NULL, cr_surface_free, surface); + return TypedData_Wrap_Struct (klass, &cr_surface_type, surface); } else { return Qnil; } @@ -482,10 +494,10 @@ } static VALUE cr_surface_allocate (VALUE klass) { - return Data_Wrap_Struct (klass, NULL, cr_surface_free, NULL); + return TypedData_Wrap_Struct (klass, &cr_surface_type, NULL); } static VALUE cr_surface_initialize (int argc, VALUE *argv, VALUE self) {