]> xenbits.xensource.com Git - libvirt.git/commitdiff
vboxDumpDisplay: use VIR_APPEND_ELEMENT
authorJán Tomko <jtomko@redhat.com>
Fri, 5 Feb 2016 16:40:51 +0000 (17:40 +0100)
committerJán Tomko <jtomko@redhat.com>
Tue, 9 Feb 2016 09:10:25 +0000 (10:10 +0100)
Instead of open-coding it.

src/vbox/vbox_common.c

index a5f0beb56064d8263d818d77a74b8190adaeefa5..e0f28d097ff9dce597771d18dbd90479673eb62d 100644 (file)
@@ -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,12 +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;
-        graphics = NULL;
-        def->ngraphics++;
     }
 
     ret = 0;