Skip to content

Commit d50d595

Browse files
committed
Use rb_darray_make in ujit
1 parent 2b53aff commit d50d595

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

ujit_core.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,12 @@ add_block_version(blockid_t blockid, block_t* block)
167167
// Ensure ujit_blocks is initialized for this iseq
168168
if (rb_darray_size(body->ujit_blocks) == 0) {
169169
// Initialize ujit_blocks to be as wide as body->iseq_encoded
170-
// TODO: add resize API for dary
171-
while ((unsigned)rb_darray_size(body->ujit_blocks) < body->iseq_size) {
172-
(void)rb_darray_append(&body->ujit_blocks, NULL);
170+
int32_t casted = (int32_t)body->iseq_size;
171+
if ((unsigned)casted != body->iseq_size) {
172+
rb_bug("iseq too large");
173+
}
174+
if (!rb_darray_make(&body->ujit_blocks, casted)) {
175+
rb_bug("allocation failed");
173176
}
174177

175178
// First block compiled for this iseq

0 commit comments

Comments
 (0)