ruby-changes:69658
From: Yusuke <ko1@a...>
Date: Tue, 9 Nov 2021 16:11:26 +0900 (JST)
Subject: [ruby-changes:69658] 037da50666 (master): class.c: Use ALLOC_N instead of ALLOCA_N
https://git.ruby-lang.org/ruby.git/commit/?id=037da50666 From 037da5066619e083b4770dc97cf6435892e2bebe Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Wed, 3 Nov 2021 03:59:17 +0900 Subject: class.c: Use ALLOC_N instead of ALLOCA_N --- class.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/class.c b/class.c index a11285fc97e..fc79c415b34 100644 --- a/class.c +++ b/class.c @@ -1383,13 +1383,17 @@ rb_class_descendants(VALUE klass) https://github.com/ruby/ruby/blob/trunk/class.c#L1383 rb_class_foreach_subclass(klass, class_descendants_recursive, (VALUE) &data); // this allocation may cause GC which may reduce the subclasses - data.buffer = ALLOCA_N(VALUE, data.count); + data.buffer = ALLOC_N(VALUE, data.count); data.count = 0; // enumerate subclasses rb_class_foreach_subclass(klass, class_descendants_recursive, (VALUE) &data); - return rb_ary_new_from_values(data.count, data.buffer); + VALUE ary = rb_ary_new_from_values(data.count, data.buffer); + + free(data.buffer); + + return ary; } static void -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/