Re: [PATCHv3 1/5] conf: Add helper to free domain list

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

 



On 08/27/2014 12:25 PM, Peter Krempa wrote:
> Add helper to free a list of virDomainPtrs without raising or clearing
> errors. Use it in one place and prepare it for reuse.
> ---
>  src/conf/domain_conf.c   | 31 +++++++++++++++++++++++--------
>  src/conf/domain_conf.h   |  2 ++
>  src/libvirt_private.syms |  1 +
>  3 files changed, 26 insertions(+), 8 deletions(-)

ACK with one minor suggestion.

> +/**
> + * virDomainListFree:
> + * @list: list of domains to free
> + *
> + * Frees the list of domains without messing with currently set libvirt errors.

Maybe mention that the list must be NULL-terminated.

> @@ -20052,13 +20073,7 @@ virDomainObjListExport(virDomainObjListPtr doms,
>      ret = data.ndomains;
> 
>   cleanup:
> -    if (data.domains) {
> -        int count = virHashSize(doms->objs);
> -        for (i = 0; i < count; i++)
> -            virObjectUnref(data.domains[i]);
> -    }
> -
> -    VIR_FREE(data.domains);
> +    virDomainListFree(data.domains);

I had to check, but yes, this conversion is correct (data.domains was
allocated earlier as virHashSize(doms->objs)+1, so it is NULL-terminated
without having to grab the hash size a second time).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]