From 50072c71abcf9a313445f188fa6405dbba1e00ba Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 25 Jul 2025 13:20:40 +0900 Subject: [PATCH] variable.c: clarify memory allocation calls Co-authored-by: Gemini --- src/variable.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/variable.c b/src/variable.c index 74535a8a7..8879d4dda 100644 --- a/src/variable.c +++ b/src/variable.c @@ -47,7 +47,7 @@ iv_rehash(mrb_state *mrb, iv_tbl *t) mrb_value *old_ptr = t->ptr; /* allocate exactly the same total shape as before */ - t->ptr = (mrb_value*)mrb_calloc(mrb, sizeof(mrb_value)+sizeof(mrb_sym), new_alloc); + t->ptr = (mrb_value*)mrb_calloc(mrb, new_alloc, sizeof(mrb_value)+sizeof(mrb_sym)); /* size remains unchanged, alloc grows */ t->alloc = new_alloc; @@ -219,7 +219,7 @@ iv_copy(mrb_state *mrb, iv_tbl *t) t2->size = t->size; /* allocate the same block shape */ - t2->ptr = (mrb_value*)mrb_calloc(mrb, sizeof(mrb_value)+sizeof(mrb_sym), t2->alloc); + t2->ptr = (mrb_value*)mrb_calloc(mrb, t2->alloc, sizeof(mrb_value)+sizeof(mrb_sym)); /* copy values[0...size] and keys[0...size] */ memcpy(t2->ptr, t->ptr, sizeof(mrb_value)*t2->size);