]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage: Use VIR_DELETE_ELEMENT instead of open coding
authorPeter Krempa <pkrempa@redhat.com>
Thu, 19 Dec 2013 11:24:26 +0000 (12:24 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 6 Jan 2014 15:05:31 +0000 (16:05 +0100)
Replace the open coded array element deletion by our new helper.

src/storage/storage_driver.c

index baba9c92829e70add02db1a7aafb42111dc21e78..aaa0f0286d475e7d8171dc01d0a28f69f5c198db 100644 (file)
@@ -1565,17 +1565,8 @@ storageVolDelete(virStorageVolPtr obj,
             VIR_INFO("Deleting volume '%s' from storage pool '%s'",
                      vol->name, pool->def->name);
             virStorageVolDefFree(vol);
-            vol = NULL;
-
-            if (i < (pool->volumes.count - 1))
-                memmove(pool->volumes.objs + i, pool->volumes.objs + i + 1,
-                        sizeof(*(pool->volumes.objs)) * (pool->volumes.count - (i + 1)));
-
-            if (VIR_REALLOC_N(pool->volumes.objs, pool->volumes.count - 1) < 0) {
-                ; /* Failure to reduce memory allocation isn't fatal */
-            }
-            pool->volumes.count--;
 
+            VIR_DELETE_ELEMENT(pool->volumes.objs, pool->volumes.count, i);
             break;
         }
     }