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

[libvirt] [PATCHv2 11/11] test: use VIR_DELETE_ELEMENTS_N for qemuMonitorTest list



---
 tests/qemumonitortestutils.c | 20 ++------------------
 1 file changed, 2 insertions(+), 18 deletions(-)

diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index 7133c99..bc10270 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -133,15 +133,7 @@ static int qemuMonitorTestProcessCommandJSON(qemuMonitorTestPtr test,
         ret = qemuMonitorTestAddReponse(test,
                                         test->items[0]->response);
         qemuMonitorTestItemFree(test->items[0]);
-        if (test->nitems == 1) {
-            VIR_FREE(test->items);
-            test->nitems = 0;
-        } else {
-            memmove(test->items,
-                    test->items + 1,
-                    sizeof(test->items[0]) * (test->nitems - 1));
-            VIR_SHRINK_N(test->items, test->nitems, 1);
-        }
+        ignore_value(VIR_DELETE_ELEMENTS_N(test->items, 0, test->nitems, 1));
     }
 
 cleanup:
@@ -176,15 +168,7 @@ static int qemuMonitorTestProcessCommandText(qemuMonitorTestPtr test,
         ret = qemuMonitorTestAddReponse(test,
                                         test->items[0]->response);
         qemuMonitorTestItemFree(test->items[0]);
-        if (test->nitems == 1) {
-            VIR_FREE(test->items);
-            test->nitems = 0;
-        } else {
-            memmove(test->items,
-                    test->items + 1,
-                    sizeof(test->items[0]) * (test->nitems - 1));
-            VIR_SHRINK_N(test->items, test->nitems, 1);
-        }
+        ignore_value(VIR_DELETE_ELEMENTS_N(test->items, 0, test->nitems, 1));
     }
 
 cleanup:
-- 
1.7.11.7


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