On 07/05/2015 07:51, Liviu Ionescu wrote: > >> On 06 May 2015, at 17:57, Leon Alrae <leon.al...@imgtec.com> wrote: >> >> +static int add_semihosting_arg(const char *name, const char *val, void >> *opaque) >> +{ >> + SemihostingConfig *s = opaque; >> + if (strcmp(name, "arg") == 0) { >> + s->argc++; >> + s->argv = g_realloc(s->argv, s->argc * sizeof(void *)); >> + s->argv[s->argc - 1] = val; >> + } >> + return 0; >> +} > > being done at init time probably it has no impact, but, as a matter of style, > I would avoid iterating realloc when the buffer size is actually known.
At this point QEMU doesn't know the buffer size, thus we need to traverse the list of sub-arguments to determine the number of args and also to get the value (i.e. string) of each arg. > > is it that difficult to count the "arg"s and correctly alloc the array? This probably would require going through the list twice which wouldn't be better in my opinion. Leon