1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-26 03:21:44 +03:00

conf: Add helper to free domain list

Add helper to free a list of virDomainPtrs without raising or clearing
errors. Use it in one place and prepare it for reuse.
This commit is contained in:
Peter Krempa 2014-08-27 14:56:45 +02:00
parent f284ee54ba
commit e41512246c
3 changed files with 27 additions and 8 deletions

View File

@ -20020,6 +20020,29 @@ virDomainListPopulate(void *payload,
}
#undef MATCH
/**
* virDomainListFree:
* @list: list of domains to free
*
* Frees a NULL-terminated list of domains without messing with currently
* set libvirt errors.
*/
void
virDomainListFree(virDomainPtr *list)
{
virDomainPtr *next;
if (!list)
return;
for (next = list; *next; next++)
virObjectUnref(*next);
VIR_FREE(list);
}
int
virDomainObjListExport(virDomainObjListPtr doms,
virConnectPtr conn,
@ -20028,7 +20051,6 @@ virDomainObjListExport(virDomainObjListPtr doms,
unsigned int flags)
{
int ret = -1;
size_t i;
struct virDomainListData data = {
conn, NULL,
@ -20056,13 +20078,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);
virObjectUnlock(doms);
return ret;
}

View File

@ -2707,6 +2707,8 @@ int virDomainObjListExport(virDomainObjListPtr doms,
virDomainObjListFilter filter,
unsigned int flags);
void virDomainListFree(virDomainPtr *list);
int
virDomainDefMaybeAddController(virDomainDefPtr def,
int type,

View File

@ -311,6 +311,7 @@ virDomainLifecycleCrashTypeFromString;
virDomainLifecycleCrashTypeToString;
virDomainLifecycleTypeFromString;
virDomainLifecycleTypeToString;
virDomainListFree;
virDomainLiveConfigHelperMethod;
virDomainLockFailureTypeFromString;
virDomainLockFailureTypeToString;