diff options
author | Benoit Daloze <eregontp@gmail.com> | 2024-02-12 10:56:33 +0100 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2024-02-12 10:56:33 +0100 |
commit | b19d2409be0b7bac65e6e54cfb3bedc61419ec01 (patch) | |
tree | 9046a7aea28aa043053acc473646b40828ec3736 /spec/ruby/optional | |
parent | 90a746d246d51d105d7f3e0d1c2ddf7994dd2d4b (diff) |
Update to ruby/spec@ce834ad
Diffstat (limited to 'spec/ruby/optional')
-rw-r--r-- | spec/ruby/optional/capi/ext/util_spec.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/spec/ruby/optional/capi/ext/util_spec.c b/spec/ruby/optional/capi/ext/util_spec.c index 95ba71ea9d..b5bde420d2 100644 --- a/spec/ruby/optional/capi/ext/util_spec.c +++ b/spec/ruby/optional/capi/ext/util_spec.c @@ -62,22 +62,17 @@ static VALUE util_spec_rb_get_kwargs(VALUE self, VALUE keyword_hash, VALUE keys, int len = RARRAY_LENINT(keys); int values_len = req + (opt < 0 ? -1 - opt : opt); - int i = 0; - ID *ids = (ID*) malloc(sizeof(VALUE) * len); - VALUE *results = (VALUE*) malloc(sizeof(VALUE) * values_len); - int extracted = 0; - VALUE ary = Qundef; + ID *ids = (ID *)alloca(sizeof(VALUE) * len); + VALUE *results = (VALUE *)alloca(sizeof(VALUE) * values_len); - for (i = 0; i < len; i++) { + for (int i = 0; i < len; i++) { ids[i] = SYM2ID(rb_ary_entry(keys, i)); } - extracted = rb_get_kwargs(keyword_hash, ids, req, opt, results); - ary = rb_ary_new_from_values(extracted, results); - free(results); - free(ids); - return ary; + int extracted = rb_get_kwargs(keyword_hash, ids, req, opt, results); + + return rb_ary_new_from_values(extracted, results); } static VALUE util_spec_rb_long2int(VALUE self, VALUE n) { |