qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH V5 08/10] Create four opts list related function


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH V5 08/10] Create four opts list related functions
Date: Mon, 19 Nov 2012 18:16:57 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On Thu, Nov 01, 2012 at 05:12:28PM +0800, Dong Xu Wang wrote:
> +/* Create a new QemuOptsList and make its desc to the merge of first and 
> second.
> + * It will allocate space for one new QemuOptsList plus enouth space for
> + * QemuOptDesc in first and second QemuOptsList. First argument's QemuOptDesc
> + * members take precedence over second's.
> + */
> +QemuOptsList *append_opts_list(QemuOptsList *first,
> +                               QemuOptsList *second)
> +{
> +    size_t num_first_options, num_second_options;
> +    QemuOptsList *dest = NULL;
> +    int i = 0;
> +    int index = 0;
> +
> +    num_first_options = count_opts_list(first);
> +    num_second_options = count_opts_list(second);
> +    if (num_first_options + num_second_options == 0) {
> +        return NULL;
> +    }
> +
> +    dest = g_malloc0(sizeof(QemuOptsList)
> +        + (num_first_options + num_second_options) * sizeof(QemuOptDesc));

(num_first_options + num_second_options + 1) since we assign
desc[index].name = NULL at the end.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]