ruby-changes:63470
From: Aaron <ko1@a...>
Date: Thu, 29 Oct 2020 10:35:49 +0900 (JST)
Subject: [ruby-changes:63470] 9f3adaf529 (master): Use public allocators for creating new T_OBJECT objects
https://git.ruby-lang.org/ruby.git/commit/?id=9f3adaf529 From 9f3adaf5293d6347250df218bad9dcd3cd8da9ba Mon Sep 17 00:00:00 2001 From: Aaron Patterson <tenderlove@r...> Date: Wed, 28 Oct 2020 16:58:17 -0700 Subject: Use public allocators for creating new T_OBJECT objects This way the header flags and object internals are set correctly diff --git a/ext/socket/ancdata.c b/ext/socket/ancdata.c index e0fc247..546a971 100644 --- a/ext/socket/ancdata.c +++ b/ext/socket/ancdata.c @@ -88,9 +88,9 @@ ancillary_initialize(VALUE self, VALUE vfamily, VALUE vlevel, VALUE vtype, VALUE https://github.com/ruby/ruby/blob/trunk/ext/socket/ancdata.c#L88 static VALUE ancdata_new(int family, int level, int type, VALUE data) { - NEWOBJ_OF(obj, struct RObject, rb_cAncillaryData, T_OBJECT); + VALUE obj = rb_obj_alloc(rb_cAncillaryData); StringValue(data); - ancillary_initialize((VALUE)obj, INT2NUM(family), INT2NUM(level), INT2NUM(type), data); + ancillary_initialize(obj, INT2NUM(family), INT2NUM(level), INT2NUM(type), data); return (VALUE)obj; } diff --git a/ext/socket/option.c b/ext/socket/option.c index 5ad44cd..4b33b3f 100644 --- a/ext/socket/option.c +++ b/ext/socket/option.c @@ -106,9 +106,9 @@ sockopt_initialize(VALUE self, VALUE vfamily, VALUE vlevel, VALUE voptname, VALU https://github.com/ruby/ruby/blob/trunk/ext/socket/option.c#L106 VALUE rsock_sockopt_new(int family, int level, int optname, VALUE data) { - NEWOBJ_OF(obj, struct RObject, rb_cSockOpt, T_OBJECT); + VALUE obj = rb_obj_alloc(rb_cSockOpt); StringValue(data); - sockopt_initialize((VALUE)obj, INT2NUM(family), INT2NUM(level), INT2NUM(optname), data); + sockopt_initialize(obj, INT2NUM(family), INT2NUM(level), INT2NUM(optname), data); return (VALUE)obj; } diff --git a/range.c b/range.c index 15b3d57..2939ef3 100644 --- a/range.c +++ b/range.c @@ -1676,10 +1676,7 @@ r_cover_p(VALUE range, VALUE beg, VALUE end, VALUE val) https://github.com/ruby/ruby/blob/trunk/range.c#L1676 static VALUE range_dumper(VALUE range) { - VALUE v; - NEWOBJ_OF(m, struct RObject, rb_cObject, T_OBJECT | (RGENGC_WB_PROTECTED_OBJECT ? FL_WB_PROTECTED : 1)); - - v = (VALUE)m; + VALUE v = rb_obj_alloc(rb_cObject); rb_ivar_set(v, id_excl, RANGE_EXCL(range)); rb_ivar_set(v, id_beg, RANGE_BEG(range)); -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/