From 89175b222f15a7929a4f9a8b11bb67c728fc8830 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Wed, 14 Feb 2024 12:04:48 -0500 Subject: [PATCH] [Feature #20265] Remove rb_newobj_of and RB_NEWOBJ_OF --- optional/capi/ext/object_spec.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/optional/capi/ext/object_spec.c b/optional/capi/ext/object_spec.c index f00e9d190..8aa98cc5c 100644 --- a/optional/capi/ext/object_spec.c +++ b/optional/capi/ext/object_spec.c @@ -384,16 +384,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; }