diff options
author | Yusuke Endoh <mame@ruby-lang.org> | 2021-11-03 03:59:17 +0900 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2021-11-09 16:11:10 +0900 |
commit | 037da5066619e083b4770dc97cf6435892e2bebe (patch) | |
tree | b781de51b94c3e378b29c55ea6709a7ff8cdd432 | |
parent | 428227472fc6563046d8138aab17f07bef6af753 (diff) | |
download | ruby-037da5066619e083b4770dc97cf6435892e2bebe.tar.gz |
class.c: Use ALLOC_N instead of ALLOCA_N
-rw-r--r-- | class.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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 |