From 07b4567df86bac168080571f1efdf7075b74f496 Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Tue, 16 Feb 2021 21:03:20 -0500 Subject: [PATCH] Use rb_darray_make in ujit --- ujit_core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ujit_core.c b/ujit_core.c index efaa33c09a3812..a4679e14759858 100644 --- a/ujit_core.c +++ b/ujit_core.c @@ -167,9 +167,12 @@ add_block_version(blockid_t blockid, block_t* block) // Ensure ujit_blocks is initialized for this iseq if (rb_darray_size(body->ujit_blocks) == 0) { // Initialize ujit_blocks to be as wide as body->iseq_encoded - // TODO: add resize API for dary - while ((unsigned)rb_darray_size(body->ujit_blocks) < body->iseq_size) { - (void)rb_darray_append(&body->ujit_blocks, NULL); + int32_t casted = (int32_t)body->iseq_size; + if ((unsigned)casted != body->iseq_size) { + rb_bug("iseq too large"); + } + if (!rb_darray_make(&body->ujit_blocks, casted)) { + rb_bug("allocation failed"); } // First block compiled for this iseq