[PATCH 08/13] src/rpc: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT

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

 



Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/rpc/virnetclient.c | 11 +----------
 src/rpc/virnetserver.c | 11 ++---------
 2 files changed, 3 insertions(+), 19 deletions(-)

diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index 9deec9e..327768b 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -920,16 +920,7 @@ void virNetClientRemoveStream(virNetClientPtr client,
     if (i == client->nstreams)
         goto cleanup;
 
-    if (client->nstreams > 1) {
-        memmove(client->streams + i,
-                client->streams + i + 1,
-                sizeof(*client->streams) *
-                (client->nstreams - (i + 1)));
-        VIR_SHRINK_N(client->streams, client->nstreams, 1);
-    } else {
-        VIR_FREE(client->streams);
-        client->nstreams = 0;
-    }
+    VIR_DELETE_ELEMENT(client->streams, i, client->nstreams);
     virObjectUnref(st);
 
 cleanup:
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index f70e260..bcabfcd 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -1130,15 +1130,8 @@ void virNetServerRun(virNetServerPtr srv)
                 virNetServerClientClose(srv->clients[i]);
             if (virNetServerClientIsClosed(srv->clients[i])) {
                 virNetServerClientPtr client = srv->clients[i];
-                if (srv->nclients > 1) {
-                    memmove(srv->clients + i,
-                            srv->clients + i + 1,
-                            sizeof(*srv->clients) * (srv->nclients - (i + 1)));
-                    VIR_SHRINK_N(srv->clients, srv->nclients, 1);
-                } else {
-                    VIR_FREE(srv->clients);
-                    srv->nclients = 0;
-                }
+
+                VIR_DELETE_ELEMENT(srv->clients, i, srv->nclients);
 
                 /* Enable services if we can accept a new client.
                  * The new client can be accepted if we are at the limit. */
-- 
1.9.0

--
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]