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