conf: new function virDomainNetDefClear

We need to clear these out without freeing the object completely.
This commit is contained in:
Laine Stump 2016-06-21 14:22:15 -04:00
parent 70a2c7e062
commit 7cfbaad189
3 changed files with 15 additions and 1 deletions

View File

@ -1737,7 +1737,8 @@ virDomainActualNetDefFree(virDomainActualNetDefPtr def)
VIR_FREE(def);
}
void virDomainNetDefFree(virDomainNetDefPtr def)
void
virDomainNetDefClear(virDomainNetDefPtr def)
{
size_t i;
@ -1753,6 +1754,7 @@ void virDomainNetDefFree(virDomainNetDefPtr def)
case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
virDomainChrSourceDefFree(def->data.vhostuser);
def->data.vhostuser = NULL;
break;
case VIR_DOMAIN_NET_TYPE_SERVER:
@ -1767,6 +1769,7 @@ void virDomainNetDefFree(virDomainNetDefPtr def)
VIR_FREE(def->data.network.name);
VIR_FREE(def->data.network.portgroup);
virDomainActualNetDefFree(def->data.network.actual);
def->data.network.actual = NULL;
break;
case VIR_DOMAIN_NET_TYPE_BRIDGE:
@ -1811,10 +1814,19 @@ void virDomainNetDefFree(virDomainNetDefPtr def)
VIR_FREE(def->filter);
virNWFilterHashTableFree(def->filterparams);
def->filterparams = NULL;
virNetDevBandwidthFree(def->bandwidth);
def->bandwidth = NULL;
virNetDevVlanClear(&def->vlan);
}
void
virDomainNetDefFree(virDomainNetDefPtr def)
{
if (!def)
return;
virDomainNetDefClear(def);
VIR_FREE(def);
}

View File

@ -2492,6 +2492,7 @@ virDomainControllerDefPtr
virDomainControllerDefNew(virDomainControllerType type);
void virDomainFSDefFree(virDomainFSDefPtr def);
void virDomainActualNetDefFree(virDomainActualNetDefPtr def);
void virDomainNetDefClear(virDomainNetDefPtr def);
void virDomainNetDefFree(virDomainNetDefPtr def);
void virDomainSmartcardDefFree(virDomainSmartcardDefPtr def);
void virDomainChrDefFree(virDomainChrDefPtr def);

View File

@ -372,6 +372,7 @@ virDomainMemoryFindInactiveByDef;
virDomainMemoryInsert;
virDomainMemoryRemove;
virDomainNetAppendIPAddress;
virDomainNetDefClear;
virDomainNetDefFormat;
virDomainNetDefFree;
virDomainNetFind;