[PATCH v1 07/31] virNetworkObjListExport: Pass virNetworkObjListPtr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Instead of copying the whole object onto stack when calling the
function, just pass the pointer to the object and save up some
space on the stack. Moreover, this prepares the code to hide the
virNetworkObjList structure into network_conf.c and use accessors
only.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/conf/network_conf.c           | 8 ++++----
 src/conf/network_conf.h           | 2 +-
 src/network/bridge_driver.c       | 2 +-
 src/parallels/parallels_network.c | 2 +-
 src/test/test_driver.c            | 2 +-
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 9734a7f..00be8b6 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -4239,7 +4239,7 @@ virNetworkMatch(virNetworkObjPtr netobj,
 
 int
 virNetworkObjListExport(virConnectPtr conn,
-                        virNetworkObjList netobjs,
+                        virNetworkObjListPtr netobjs,
                         virNetworkPtr **nets,
                         virNetworkObjListFilter filter,
                         unsigned int flags)
@@ -4250,11 +4250,11 @@ virNetworkObjListExport(virConnectPtr conn,
     int ret = -1;
     size_t i;
 
-    if (nets && VIR_ALLOC_N(tmp_nets, netobjs.count + 1) < 0)
+    if (nets && VIR_ALLOC_N(tmp_nets, netobjs->count + 1) < 0)
         goto cleanup;
 
-    for (i = 0; i < netobjs.count; i++) {
-        virNetworkObjPtr netobj = netobjs.objs[i];
+    for (i = 0; i < netobjs->count; i++) {
+        virNetworkObjPtr netobj = netobjs->objs[i];
         virNetworkObjLock(netobj);
         if ((!filter || filter(conn, netobj->def)) &&
             virNetworkMatch(netobj, flags)) {
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index 70e6eb5..74665e0 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -440,7 +440,7 @@ VIR_ENUM_DECL(virNetworkForward)
                  VIR_CONNECT_LIST_NETWORKS_FILTERS_AUTOSTART)
 
 int virNetworkObjListExport(virConnectPtr conn,
-                            virNetworkObjList netobjs,
+                            virNetworkObjListPtr netobjs,
                             virNetworkPtr **nets,
                             virNetworkObjListFilter filter,
                             unsigned int flags);
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 019cb41..edc4ed4 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -2638,7 +2638,7 @@ networkConnectListAllNetworks(virConnectPtr conn,
         goto cleanup;
 
     networkDriverLock();
-    ret = virNetworkObjListExport(conn, driver->networks, nets,
+    ret = virNetworkObjListExport(conn, &driver->networks, nets,
                                   virConnectListAllNetworksCheckACL,
                                   flags);
     networkDriverUnlock();
diff --git a/src/parallels/parallels_network.c b/src/parallels/parallels_network.c
index 3e7087d..960bd50 100644
--- a/src/parallels/parallels_network.c
+++ b/src/parallels/parallels_network.c
@@ -449,7 +449,7 @@ static int parallelsConnectListAllNetworks(virConnectPtr conn,
     virCheckFlags(VIR_CONNECT_LIST_NETWORKS_FILTERS_ALL, -1);
 
     parallelsDriverLock(privconn);
-    ret = virNetworkObjListExport(conn, privconn->networks, nets, NULL, flags);
+    ret = virNetworkObjListExport(conn, &privconn->networks, nets, NULL, flags);
     parallelsDriverUnlock(privconn);
 
     return ret;
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 2bed3f2..e2da1e2 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -3636,7 +3636,7 @@ testConnectListAllNetworks(virConnectPtr conn,
     virCheckFlags(VIR_CONNECT_LIST_NETWORKS_FILTERS_ALL, -1);
 
     testDriverLock(privconn);
-    ret = virNetworkObjListExport(conn, privconn->networks, nets, NULL, flags);
+    ret = virNetworkObjListExport(conn, &privconn->networks, nets, NULL, flags);
     testDriverUnlock(privconn);
 
     return ret;
-- 
2.0.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]