]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virNWFilterVarCombIter: Allocate 'iter' member separately
authorPeter Krempa <pkrempa@redhat.com>
Wed, 3 Feb 2021 12:42:00 +0000 (13:42 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 3 Feb 2021 15:09:25 +0000 (16:09 +0100)
Switch to the more common approach of having arrays allocated separately
rather than trailing the struct.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/conf/nwfilter_params.c
src/conf/nwfilter_params.h

index 18b64e373b2a89ffd9037d66f0dae9c18379e760..1be492759a0083591baf8a239e66a7281d6a70c0 100644 (file)
@@ -304,6 +304,8 @@ virNWFilterVarCombIterFree(virNWFilterVarCombIterPtr ci)
     for (i = 0; i < ci->nIter; i++)
         g_free(ci->iter[i].varNames);
 
+    g_free(ci->iter);
+
     g_free(ci);
 }
 
@@ -465,8 +467,8 @@ virNWFilterVarCombIterCreate(GHashTable *hash,
     int iterIndex = -1;
     unsigned int nextIntIterId = VIR_NWFILTER_MAX_ITERID + 1;
 
-    if (VIR_ALLOC_VAR(res, virNWFilterVarCombIterEntry, 1 + nVarAccess) < 0)
-        return NULL;
+    res = g_new0(virNWFilterVarCombIter, 1);
+    res->iter = g_new0(virNWFilterVarCombIterEntry, nVarAccess + 1);
 
     res->hashTable = hash;
 
index 05a6a43399de4a2f98ba106849c14208c95e6227..59068b8ae92dd61029eb8c3ef020819e5bd83bb4 100644 (file)
@@ -137,7 +137,7 @@ typedef virNWFilterVarCombIter *virNWFilterVarCombIterPtr;
 struct _virNWFilterVarCombIter {
     GHashTable *hashTable;
     size_t nIter;
-    virNWFilterVarCombIterEntry iter[0];
+    virNWFilterVarCombIterEntryPtr iter;
 };
 virNWFilterVarCombIterPtr virNWFilterVarCombIterCreate(
                              GHashTable *hash,