mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 09:53:10 +00: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:
parent
f284ee54ba
commit
e41512246c
@ -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;
|
||||
}
|
||||
|
@ -2707,6 +2707,8 @@ int virDomainObjListExport(virDomainObjListPtr doms,
|
||||
virDomainObjListFilter filter,
|
||||
unsigned int flags);
|
||||
|
||||
void virDomainListFree(virDomainPtr *list);
|
||||
|
||||
int
|
||||
virDomainDefMaybeAddController(virDomainDefPtr def,
|
||||
int type,
|
||||
|
@ -311,6 +311,7 @@ virDomainLifecycleCrashTypeFromString;
|
||||
virDomainLifecycleCrashTypeToString;
|
||||
virDomainLifecycleTypeFromString;
|
||||
virDomainLifecycleTypeToString;
|
||||
virDomainListFree;
|
||||
virDomainLiveConfigHelperMethod;
|
||||
virDomainLockFailureTypeFromString;
|
||||
virDomainLockFailureTypeToString;
|
||||
|
Loading…
Reference in New Issue
Block a user