don't use vla

This commit is contained in:
Yuichi Nishiwaki 2015-07-13 09:27:12 +09:00
parent 803d7f0ad6
commit f6bb2ce178
2 changed files with 13 additions and 12 deletions

View File

@ -157,19 +157,19 @@ pic_callcc(pic_state *pic, struct pic_proc *proc)
static pic_value static pic_value
pic_va_values(pic_state *pic, size_t n, ...) pic_va_values(pic_state *pic, size_t n, ...)
{ {
pic_value args[n]; pic_vec *args = pic_make_vec(pic, n);
va_list ap; va_list ap;
size_t i = 0; size_t i = 0;
va_start(ap, n); va_start(ap, n);
while (i < n) { while (i < n) {
args[i++] = va_arg(ap, pic_value); args->data[i++] = va_arg(ap, pic_value);
} }
va_end(ap); va_end(ap);
return pic_values(pic, n, args); return pic_values(pic, n, args->data);
} }
pic_value pic_value
@ -288,19 +288,19 @@ static pic_value
pic_cont_call_with_values(pic_state *pic) pic_cont_call_with_values(pic_state *pic)
{ {
struct pic_proc *producer, *consumer; struct pic_proc *producer, *consumer;
size_t argc;
pic_vec *args;
pic_get_args(pic, "ll", &producer, &consumer); pic_get_args(pic, "ll", &producer, &consumer);
pic_apply(pic, producer, pic_nil_value()); pic_apply(pic, producer, pic_nil_value());
do { argc = pic_receive(pic, 0, NULL);
size_t argc = pic_receive(pic, 0, NULL); args = pic_make_vec(pic, argc);
pic_value args[argc];
pic_receive(pic, argc, args); pic_receive(pic, argc, args->data);
return pic_apply_trampoline(pic, consumer, argc, args); return pic_apply_trampoline(pic, consumer, argc, args->data);
} while (0);
} }
void void

View File

@ -1046,14 +1046,15 @@ pic_value
pic_apply_trampoline_list(pic_state *pic, struct pic_proc *proc, pic_value args) pic_apply_trampoline_list(pic_state *pic, struct pic_proc *proc, pic_value args)
{ {
size_t i, argc = pic_length(pic, args); size_t i, argc = pic_length(pic, args);
pic_value val, it, argv[argc]; pic_value val, it;
pic_vec *argv = pic_make_vec(pic, argc);
i = 0; i = 0;
pic_for_each (val, args, it) { pic_for_each (val, args, it) {
argv[i++] = val; argv->data[i++] = val;
} }
return pic_apply_trampoline(pic, proc, argc, argv); return pic_apply_trampoline(pic, proc, argc, argv->data);
} }
pic_value pic_value