mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
conf: nwfilter: Replace 'virNWFilterHashTableCreate' with 'virHashNew'
Export the freeing function rather than having a wrapper for the hash creation function. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
c28b680579
commit
e12324d2af
@ -59,7 +59,7 @@ virNWFilterBindingDefForNet(const char *vmname,
|
|||||||
|
|
||||||
ret->filter = g_strdup(net->filter);
|
ret->filter = g_strdup(net->filter);
|
||||||
|
|
||||||
if (!(ret->filterparams = virNWFilterHashTableCreate(0)))
|
if (!(ret->filterparams = virHashNew(virNWFilterVarValueHashFree)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (net->filterparams &&
|
if (net->filterparams &&
|
||||||
|
@ -149,7 +149,7 @@ virNWFilterIPAddrMapGetIPAddr(const char *ifname)
|
|||||||
int
|
int
|
||||||
virNWFilterIPAddrMapInit(void)
|
virNWFilterIPAddrMapInit(void)
|
||||||
{
|
{
|
||||||
ipAddressMap = virNWFilterHashTableCreate(0);
|
ipAddressMap = virHashNew(virNWFilterVarValueHashFree);
|
||||||
if (!ipAddressMap)
|
if (!ipAddressMap)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -606,19 +606,13 @@ virNWFilterVarCombIterGetVarValue(virNWFilterVarCombIterPtr ci,
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
hashDataFree(void *payload)
|
virNWFilterVarValueHashFree(void *payload)
|
||||||
{
|
{
|
||||||
virNWFilterVarValueFree(payload);
|
virNWFilterVarValueFree(payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virHashTablePtr
|
|
||||||
virNWFilterHashTableCreate(int n)
|
|
||||||
{
|
|
||||||
return virHashCreate(n, hashDataFree);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct addToTableStruct {
|
struct addToTableStruct {
|
||||||
virHashTablePtr target;
|
virHashTablePtr target;
|
||||||
int errOccurred;
|
int errOccurred;
|
||||||
@ -708,7 +702,7 @@ virNWFilterParseParamAttributes(xmlNodePtr cur)
|
|||||||
char *nam, *val;
|
char *nam, *val;
|
||||||
virNWFilterVarValuePtr value;
|
virNWFilterVarValuePtr value;
|
||||||
|
|
||||||
virHashTablePtr table = virNWFilterHashTableCreate(0);
|
virHashTablePtr table = virHashNew(virNWFilterVarValueHashFree);
|
||||||
if (!table)
|
if (!table)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ virNWFilterVarValuePtr virNWFilterVarValueCreateSimple(char *);
|
|||||||
virNWFilterVarValuePtr virNWFilterVarValueCreateSimpleCopyValue(const char *);
|
virNWFilterVarValuePtr virNWFilterVarValueCreateSimpleCopyValue(const char *);
|
||||||
virNWFilterVarValuePtr virNWFilterVarValueCopy(const virNWFilterVarValue *);
|
virNWFilterVarValuePtr virNWFilterVarValueCopy(const virNWFilterVarValue *);
|
||||||
void virNWFilterVarValueFree(virNWFilterVarValuePtr val);
|
void virNWFilterVarValueFree(virNWFilterVarValuePtr val);
|
||||||
|
void virNWFilterVarValueHashFree(void *payload);
|
||||||
const char *virNWFilterVarValueGetSimple(const virNWFilterVarValue *val);
|
const char *virNWFilterVarValueGetSimple(const virNWFilterVarValue *val);
|
||||||
const char *virNWFilterVarValueGetNthValue(const virNWFilterVarValue *val,
|
const char *virNWFilterVarValueGetNthValue(const virNWFilterVarValue *val,
|
||||||
unsigned int idx);
|
unsigned int idx);
|
||||||
@ -67,7 +68,6 @@ int virNWFilterFormatParamAttributes(virBufferPtr buf,
|
|||||||
virHashTablePtr table,
|
virHashTablePtr table,
|
||||||
const char *filterref);
|
const char *filterref);
|
||||||
|
|
||||||
virHashTablePtr virNWFilterHashTableCreate(int n);
|
|
||||||
int virNWFilterHashTablePutAll(virHashTablePtr src,
|
int virNWFilterHashTablePutAll(virHashTablePtr src,
|
||||||
virHashTablePtr dest);
|
virHashTablePtr dest);
|
||||||
bool virNWFilterHashTableEqual(virHashTablePtr a,
|
bool virNWFilterHashTableEqual(virHashTablePtr a,
|
||||||
|
@ -65,7 +65,7 @@ virNWFilterBindingDefCopy(virNWFilterBindingDefPtr src)
|
|||||||
|
|
||||||
ret->filter = g_strdup(src->filter);
|
ret->filter = g_strdup(src->filter);
|
||||||
|
|
||||||
if (!(ret->filterparams = virNWFilterHashTableCreate(0)))
|
if (!(ret->filterparams = virHashNew(virNWFilterVarValueHashFree)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (virNWFilterHashTablePutAll(src->filterparams, ret->filterparams) < 0)
|
if (virNWFilterHashTablePutAll(src->filterparams, ret->filterparams) < 0)
|
||||||
|
@ -927,7 +927,6 @@ virNWFilterIPAddrMapShutdown;
|
|||||||
|
|
||||||
|
|
||||||
# conf/nwfilter_params.h
|
# conf/nwfilter_params.h
|
||||||
virNWFilterHashTableCreate;
|
|
||||||
virNWFilterHashTableEqual;
|
virNWFilterHashTableEqual;
|
||||||
virNWFilterHashTablePutAll;
|
virNWFilterHashTablePutAll;
|
||||||
virNWFilterVarAccessGetVarName;
|
virNWFilterVarAccessGetVarName;
|
||||||
@ -948,6 +947,7 @@ virNWFilterVarValueFree;
|
|||||||
virNWFilterVarValueGetCardinality;
|
virNWFilterVarValueGetCardinality;
|
||||||
virNWFilterVarValueGetNthValue;
|
virNWFilterVarValueGetNthValue;
|
||||||
virNWFilterVarValueGetSimple;
|
virNWFilterVarValueGetSimple;
|
||||||
|
virNWFilterVarValueHashFree;
|
||||||
|
|
||||||
|
|
||||||
# conf/object_event.h
|
# conf/object_event.h
|
||||||
|
@ -199,7 +199,7 @@ static virHashTablePtr
|
|||||||
virNWFilterCreateVarsFrom(virHashTablePtr vars1,
|
virNWFilterCreateVarsFrom(virHashTablePtr vars1,
|
||||||
virHashTablePtr vars2)
|
virHashTablePtr vars2)
|
||||||
{
|
{
|
||||||
virHashTablePtr res = virNWFilterHashTableCreate(0);
|
virHashTablePtr res = virHashNew(virNWFilterVarValueHashFree);
|
||||||
if (!res)
|
if (!res)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -268,7 +268,7 @@ virNWFilterRuleDefToRuleInst(virNWFilterDefPtr def,
|
|||||||
ruleinst->chainPriority = def->chainPriority;
|
ruleinst->chainPriority = def->chainPriority;
|
||||||
ruleinst->def = rule;
|
ruleinst->def = rule;
|
||||||
ruleinst->priority = rule->priority;
|
ruleinst->priority = rule->priority;
|
||||||
if (!(ruleinst->vars = virNWFilterHashTableCreate(0)))
|
if (!(ruleinst->vars = virHashNew(virNWFilterVarValueHashFree)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (virNWFilterHashTablePutAll(vars, ruleinst->vars) < 0)
|
if (virNWFilterHashTablePutAll(vars, ruleinst->vars) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -516,7 +516,7 @@ virNWFilterDoInstantiate(virNWFilterTechDriverPtr techdriver,
|
|||||||
const char *learning;
|
const char *learning;
|
||||||
bool reportIP = false;
|
bool reportIP = false;
|
||||||
|
|
||||||
virHashTablePtr missing_vars = virNWFilterHashTableCreate(0);
|
virHashTablePtr missing_vars = virHashNew(virNWFilterVarValueHashFree);
|
||||||
|
|
||||||
memset(&inst, 0, sizeof(inst));
|
memset(&inst, 0, sizeof(inst));
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ static virHashTablePtr
|
|||||||
virNWFilterCreateVarsFrom(virHashTablePtr vars1,
|
virNWFilterCreateVarsFrom(virHashTablePtr vars1,
|
||||||
virHashTablePtr vars2)
|
virHashTablePtr vars2)
|
||||||
{
|
{
|
||||||
virHashTablePtr res = virNWFilterHashTableCreate(0);
|
virHashTablePtr res = virHashNew(virNWFilterVarValueHashFree);
|
||||||
if (!res)
|
if (!res)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ virNWFilterRuleDefToRuleInst(virNWFilterDefPtr def,
|
|||||||
ruleinst->chainPriority = def->chainPriority;
|
ruleinst->chainPriority = def->chainPriority;
|
||||||
ruleinst->def = rule;
|
ruleinst->def = rule;
|
||||||
ruleinst->priority = rule->priority;
|
ruleinst->priority = rule->priority;
|
||||||
if (!(ruleinst->vars = virNWFilterHashTableCreate(0)))
|
if (!(ruleinst->vars = virHashNew(virNWFilterVarValueHashFree)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (virNWFilterHashTablePutAll(vars, ruleinst->vars) < 0)
|
if (virNWFilterHashTablePutAll(vars, ruleinst->vars) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -368,7 +368,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
|
|||||||
{
|
{
|
||||||
char *actualargv = NULL;
|
char *actualargv = NULL;
|
||||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
virHashTablePtr vars = virNWFilterHashTableCreate(0);
|
virHashTablePtr vars = virHashNew(virNWFilterVarValueHashFree);
|
||||||
virNWFilterInst inst;
|
virNWFilterInst inst;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user