diff options
author | Peter Zhu <peter@peterzhu.ca> | 2024-02-14 12:04:48 -0500 |
---|---|---|
committer | Peter Zhu <peter@peterzhu.ca> | 2024-03-14 12:53:04 -0400 |
commit | ff51dc56540c3ba574a4b3f606bafd57788f620f (patch) | |
tree | d1b9cac40922259af9f97d1bc1980efb482a2de2 /spec/ruby/optional/capi/ext/object_spec.c | |
parent | 8e1831406ffd385213f67baba0d1fe6d44e9e0ea (diff) |
[Feature #20265] Remove rb_newobj_of and RB_NEWOBJ_OF
Diffstat (limited to 'spec/ruby/optional/capi/ext/object_spec.c')
-rw-r--r-- | spec/ruby/optional/capi/ext/object_spec.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/spec/ruby/optional/capi/ext/object_spec.c b/spec/ruby/optional/capi/ext/object_spec.c index 7023c29bdb..1d3a1ed476 100644 --- a/spec/ruby/optional/capi/ext/object_spec.c +++ b/spec/ruby/optional/capi/ext/object_spec.c @@ -388,16 +388,8 @@ static VALUE object_spec_rb_ivar_foreach(VALUE self, VALUE obj) { } static VALUE speced_allocator(VALUE klass) { - VALUE flags = 0; - VALUE instance; - if (RTEST(rb_class_inherited_p(klass, rb_cString))) { - flags = T_STRING; - } else if (RTEST(rb_class_inherited_p(klass, rb_cArray))) { - flags = T_ARRAY; - } else { - flags = T_OBJECT; - } - instance = rb_newobj_of(klass, flags); + VALUE super = rb_class_get_superclass(klass); + VALUE instance = rb_get_alloc_func(super)(klass); rb_iv_set(instance, "@from_custom_allocator", Qtrue); return instance; } |