From 391e24210fdfb3c80c86b10c1421c984ac715a13 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Wed, 18 Apr 2018 17:29:45 +0900 Subject: A new function `ary_from_values()`; ref #4004 --- src/array.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/array.c') diff --git a/src/array.c b/src/array.c index 043cd7325..e039ba3b1 100644 --- a/src/array.c +++ b/src/array.c @@ -77,14 +77,21 @@ array_copy(mrb_value *dst, const mrb_value *src, mrb_int size) } } -MRB_API mrb_value -mrb_ary_new_from_values(mrb_state *mrb, mrb_int size, const mrb_value *vals) +static struct RArray* +ary_new_from_values(mrb_state *mrb, mrb_int size, const mrb_value *vals) { struct RArray *a = ary_new_capa(mrb, size); array_copy(ARY_PTR(a), vals, size); ARY_SET_LEN(a, size); + return a; +} + +MRB_API mrb_value +mrb_ary_new_from_values(mrb_state *mrb, mrb_int size, const mrb_value *vals) +{ + struct RArray *a = ary_new_from_values(mrb, size, vals); return mrb_obj_value(a); } -- cgit v1.2.3