class.c: Use ALLOC_N instead of ALLOCA_N

This commit is contained in:
Yusuke Endoh 2021-11-03 03:59:17 +09:00
parent 428227472f
commit 037da50666
Notes: git 2021-11-09 16:11:32 +09:00

View File

@ -1383,13 +1383,17 @@ rb_class_descendants(VALUE klass)
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