On 07/05/2015 14:02, Peter Maydell 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;
>> + }
>
> Consider using a glib pointer array? Then this is just
> a call to g_pointer_array_add().
glib pointer array certainly simplifies managing an array of pointers,
but I think in this case we wouldn't benefit much from it as the array
is set here only and never modified later. Also people not familiar with
glib pointer arrays may find raw int argc and const char **argv fields
clearer than GPtrArray type.
I'll leave it as it is, but if anyone has strong preference on using
g_ptr_array I don't mind updating the patch as changes are trivial.
Thanks,
Leon