diff options
| author | ksss <[email protected]> | 2017-12-18 11:05:55 +0900 |
|---|---|---|
| committer | ksss <[email protected]> | 2017-12-18 11:05:55 +0900 |
| commit | ae786b18d5335a6b8f5715423b97a79438840776 (patch) | |
| tree | 8dc7058e300389cda11b7c1db4b024f9edcd544c /mrbgems/mruby-method | |
| parent | b83ff8ccd8294de76bf8dbdea27ace70a667688a (diff) | |
| download | mruby-ae786b18d5335a6b8f5715423b97a79438840776.tar.gz mruby-ae786b18d5335a6b8f5715423b97a79438840776.zip | |
Shouldn't use alloca
Diffstat (limited to 'mrbgems/mruby-method')
| -rw-r--r-- | mrbgems/mruby-method/src/method.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/mrbgems/mruby-method/src/method.c b/mrbgems/mruby-method/src/method.c index a40faa5ef..0ce44fd97 100644 --- a/mrbgems/mruby-method/src/method.c +++ b/mrbgems/mruby-method/src/method.c @@ -5,7 +5,6 @@ #include "mruby/variable.h" #include "mruby/proc.h" #include "mruby/string.h" -#include <alloca.h> static struct RObject * method_object_alloc(mrb_state *mrb, struct RClass *mclass) @@ -113,7 +112,7 @@ method_call(mrb_state *mrb, mrb_value self) mrb_value name = mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "@name")); mrb_value recv = mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "@recv")); struct RClass *owner = mrb_class_ptr(mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "@owner"))); - mrb_int argc, i; + mrb_int argc; mrb_value *argv, ret, block; mrb_sym orig_mid; @@ -121,12 +120,9 @@ method_call(mrb_state *mrb, mrb_value self) orig_mid = mrb->c->ci->mid; mrb->c->ci->mid = mrb_symbol(name); if (mrb_nil_p(proc)) { - mrb_value *missing_argv = (mrb_value*)alloca(sizeof(mrb_value) * (argc + 1)); - missing_argv[0] = name; - for(i = 0; i < argc; i++) { - missing_argv[i + 1] = argv[i]; - } - ret = mrb_funcall_argv(mrb, recv, mrb_intern_lit(mrb, "method_missing"), argc + 1, missing_argv); + mrb_value missing_argv = mrb_ary_new_from_values(mrb, argc, argv); + mrb_ary_unshift(mrb, missing_argv, name); + ret = mrb_funcall_argv(mrb, recv, mrb_intern_lit(mrb, "method_missing"), argc + 1, RARRAY_PTR(missing_argv)); } else if (!mrb_nil_p(block)) { /* |
