[PATCH 11/13] vboxDumpDisplay: use VIR_APPEND_ELEMENT

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

 



Instead of open-coding it.
---
 src/vbox/vbox_common.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 1c2a432..236e048 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -3363,14 +3363,9 @@ vboxDumpDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
             goto cleanup;
     }
 
-    if (graphics) {
-        if (VIR_ALLOC_N(def->graphics, 1) < 0)
-            goto cleanup;
-
-        def->graphics[def->ngraphics] = graphics;
-        graphics = NULL;
-        def->ngraphics++;
-    }
+    if (graphics &&
+        VIR_APPEND_ELEMENT(def->graphics, def->ngraphics, graphics) < 0)
+        goto cleanup;
 
     gVBoxAPI.UIMachine.GetVRDxServer(machine, &VRDxServer);
     if (VRDxServer)
@@ -3407,11 +3402,8 @@ vboxDumpDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
         if (reuseSingleConnection)
             graphics->data.rdp.replaceUser = true;
 
-        if (VIR_REALLOC_N(def->graphics, def->ngraphics + 1) < 0)
+        if (VIR_APPEND_ELEMENT(def->graphics, def->ngraphics, graphics) < 0)
             goto cleanup;
-
-        def->graphics[def->ngraphics] = graphics;
-        def->ngraphics++;
     }
 
     ret = 0;
-- 
2.4.10

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