[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 4/4] semihosting: add --semihosting-config arg s
From: |
Leon Alrae |
Subject: |
Re: [Qemu-devel] [PATCH 4/4] semihosting: add --semihosting-config arg sub-argument |
Date: |
Thu, 7 May 2015 10:52:19 +0100 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 |
On 07/05/2015 07:51, Liviu Ionescu wrote:
>
>> On 06 May 2015, at 17:57, Leon Alrae <address@hidden> 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
Re: [Qemu-devel] [PATCH 0/4] semihosting: clean up and add --semihosting-config arg, Liviu Ionescu, 2015/05/06