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:
Peter Krempa 2020-10-20 18:41:27 +02:00
parent c28b680579
commit e12324d2af
8 changed files with 14 additions and 20 deletions

View File

@ -59,7 +59,7 @@ virNWFilterBindingDefForNet(const char *vmname,
ret->filter = g_strdup(net->filter);
if (!(ret->filterparams = virNWFilterHashTableCreate(0)))
if (!(ret->filterparams = virHashNew(virNWFilterVarValueHashFree)))
goto error;
if (net->filterparams &&

View File

@ -149,7 +149,7 @@ virNWFilterIPAddrMapGetIPAddr(const char *ifname)
int
virNWFilterIPAddrMapInit(void)
{
ipAddressMap = virNWFilterHashTableCreate(0);
ipAddressMap = virHashNew(virNWFilterVarValueHashFree);
if (!ipAddressMap)
return -1;

View File

@ -606,19 +606,13 @@ virNWFilterVarCombIterGetVarValue(virNWFilterVarCombIterPtr ci,
return res;
}
static void
hashDataFree(void *payload)
void
virNWFilterVarValueHashFree(void *payload)
{
virNWFilterVarValueFree(payload);
}
virHashTablePtr
virNWFilterHashTableCreate(int n)
{
return virHashCreate(n, hashDataFree);
}
struct addToTableStruct {
virHashTablePtr target;
int errOccurred;
@ -708,7 +702,7 @@ virNWFilterParseParamAttributes(xmlNodePtr cur)
char *nam, *val;
virNWFilterVarValuePtr value;
virHashTablePtr table = virNWFilterHashTableCreate(0);
virHashTablePtr table = virHashNew(virNWFilterVarValueHashFree);
if (!table)
return NULL;

View File

@ -52,6 +52,7 @@ virNWFilterVarValuePtr virNWFilterVarValueCreateSimple(char *);
virNWFilterVarValuePtr virNWFilterVarValueCreateSimpleCopyValue(const char *);
virNWFilterVarValuePtr virNWFilterVarValueCopy(const virNWFilterVarValue *);
void virNWFilterVarValueFree(virNWFilterVarValuePtr val);
void virNWFilterVarValueHashFree(void *payload);
const char *virNWFilterVarValueGetSimple(const virNWFilterVarValue *val);
const char *virNWFilterVarValueGetNthValue(const virNWFilterVarValue *val,
unsigned int idx);
@ -67,7 +68,6 @@ int virNWFilterFormatParamAttributes(virBufferPtr buf,
virHashTablePtr table,
const char *filterref);
virHashTablePtr virNWFilterHashTableCreate(int n);
int virNWFilterHashTablePutAll(virHashTablePtr src,
virHashTablePtr dest);
bool virNWFilterHashTableEqual(virHashTablePtr a,

View File

@ -65,7 +65,7 @@ virNWFilterBindingDefCopy(virNWFilterBindingDefPtr src)
ret->filter = g_strdup(src->filter);
if (!(ret->filterparams = virNWFilterHashTableCreate(0)))
if (!(ret->filterparams = virHashNew(virNWFilterVarValueHashFree)))
goto error;
if (virNWFilterHashTablePutAll(src->filterparams, ret->filterparams) < 0)

View File

@ -927,7 +927,6 @@ virNWFilterIPAddrMapShutdown;
# conf/nwfilter_params.h
virNWFilterHashTableCreate;
virNWFilterHashTableEqual;
virNWFilterHashTablePutAll;
virNWFilterVarAccessGetVarName;
@ -948,6 +947,7 @@ virNWFilterVarValueFree;
virNWFilterVarValueGetCardinality;
virNWFilterVarValueGetNthValue;
virNWFilterVarValueGetSimple;
virNWFilterVarValueHashFree;
# conf/object_event.h

View File

@ -199,7 +199,7 @@ static virHashTablePtr
virNWFilterCreateVarsFrom(virHashTablePtr vars1,
virHashTablePtr vars2)
{
virHashTablePtr res = virNWFilterHashTableCreate(0);
virHashTablePtr res = virHashNew(virNWFilterVarValueHashFree);
if (!res)
return NULL;
@ -268,7 +268,7 @@ virNWFilterRuleDefToRuleInst(virNWFilterDefPtr def,
ruleinst->chainPriority = def->chainPriority;
ruleinst->def = rule;
ruleinst->priority = rule->priority;
if (!(ruleinst->vars = virNWFilterHashTableCreate(0)))
if (!(ruleinst->vars = virHashNew(virNWFilterVarValueHashFree)))
goto cleanup;
if (virNWFilterHashTablePutAll(vars, ruleinst->vars) < 0)
goto cleanup;
@ -516,7 +516,7 @@ virNWFilterDoInstantiate(virNWFilterTechDriverPtr techdriver,
const char *learning;
bool reportIP = false;
virHashTablePtr missing_vars = virNWFilterHashTableCreate(0);
virHashTablePtr missing_vars = virHashNew(virNWFilterVarValueHashFree);
memset(&inst, 0, sizeof(inst));

View File

@ -149,7 +149,7 @@ static virHashTablePtr
virNWFilterCreateVarsFrom(virHashTablePtr vars1,
virHashTablePtr vars2)
{
virHashTablePtr res = virNWFilterHashTableCreate(0);
virHashTablePtr res = virHashNew(virNWFilterVarValueHashFree);
if (!res)
return NULL;
@ -215,7 +215,7 @@ virNWFilterRuleDefToRuleInst(virNWFilterDefPtr def,
ruleinst->chainPriority = def->chainPriority;
ruleinst->def = rule;
ruleinst->priority = rule->priority;
if (!(ruleinst->vars = virNWFilterHashTableCreate(0)))
if (!(ruleinst->vars = virHashNew(virNWFilterVarValueHashFree)))
goto cleanup;
if (virNWFilterHashTablePutAll(vars, ruleinst->vars) < 0)
goto cleanup;
@ -368,7 +368,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
{
char *actualargv = NULL;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
virHashTablePtr vars = virNWFilterHashTableCreate(0);
virHashTablePtr vars = virHashNew(virNWFilterVarValueHashFree);
virNWFilterInst inst;
int ret = -1;