Skip to content

Commit

Permalink
class.c: Use ALLOC_N instead of ALLOCA_N
Browse files Browse the repository at this point in the history
  • Loading branch information
mame committed Nov 9, 2021
1 parent 4282274 commit 037da50
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions class.c
Expand Up @@ -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
Expand Down

0 comments on commit 037da50

Please sign in to comment.