Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/nwfilter/nwfilter_gentech_driver.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/src/nwfilter/nwfilter_gentech_driver.c
b/src/nwfilter/nwfilter_gentech_driver.c
index 8c5cd57..ef3d4bd 100644
--- a/src/nwfilter/nwfilter_gentech_driver.c
+++ b/src/nwfilter/nwfilter_gentech_driver.c
@@ -110,10 +110,7 @@ int
virNWFilterRuleInstAddData(virNWFilterRuleInstPtr res,
void *data)
{
- if (VIR_REALLOC_N(res->data, res->ndata+1) < 0)
- return -1;
- res->data[res->ndata++] = data;
- return 0;
+ return VIR_APPEND_ELEMENT(res->data, res->ndata, data);
}
@@ -381,7 +378,7 @@ _virNWFilterInstantiateRec(virNWFilterTechDriverPtr techdriver,
virNWFilterDefPtr filter,
const char *ifname,
virNWFilterHashTablePtr vars,
- int *nEntries,
+ size_t *nEntries,
virNWFilterRuleInstPtr **insts,
enum instCase useNewFilter, bool *foundNewFilter,
virNWFilterDriverStatePtr driver)
@@ -407,13 +404,11 @@ _virNWFilterInstantiateRec(virNWFilterTechDriverPtr techdriver,
break;
}
- if (VIR_REALLOC_N(*insts, (*nEntries)+1) < 0) {
+ if (VIR_APPEND_ELEMENT_COPY(*insts, *nEntries, inst) < 0) {
rc = -1;
break;
}
- (*insts)[(*nEntries)++] = inst;
-
} else if (inc) {
VIR_DEBUG("Instantiating filter %s", inc->filterref);
obj = virNWFilterObjFindByName(&driver->nwfilters,
inc->filterref);
@@ -652,7 +647,7 @@ virNWFilterInstantiate(const unsigned char *vmuuid ATTRIBUTE_UNUSED,
int rc;
size_t j;
int nptrs;
- int nEntries = 0;
+ size_t nEntries = 0;
virNWFilterRuleInstPtr *insts = NULL;
void **ptrs = NULL;
bool instantiate = true;
--
1.9.0