The stock remove functions in domain_conf.c already use
VIR_DELETE_ELEMENTS_N. This does the same in a xen file.
FIXME: This should be modified to call the helper functions in
domain_conf.c.
---
src/xen/xm_internal.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 7b3d340..7bc3ed7 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -1477,12 +1477,8 @@ xenXMDomainDetachDeviceFlags(virDomainPtr domain, const char *xml,
dev->data.disk->dst &&
STREQ(def->disks[i]->dst, dev->data.disk->dst)) {
virDomainDiskDefFree(def->disks[i]);
- if (i < (def->ndisks - 1))
- memmove(def->disks + i,
- def->disks + i + 1,
- sizeof(*def->disks) *
- (def->ndisks - (i + 1)));
- def->ndisks--;
+ ignore_value(VIR_DELETE_ELEMENTS_N(def->disks, i,
+ def->ndisks, 1));
break;
}
}
@@ -1494,12 +1490,8 @@ xenXMDomainDetachDeviceFlags(virDomainPtr domain, const char *xml,
for (i = 0 ; i < def->nnets ; i++) {
if (!virMacAddrCmp(&def->nets[i]->mac,
&dev->data.net->mac)) {
virDomainNetDefFree(def->nets[i]);
- if (i < (def->nnets - 1))
- memmove(def->nets + i,
- def->nets + i + 1,
- sizeof(*def->nets) *
- (def->nnets - (i + 1)));
- def->nnets--;
+ ignore_value(VIR_DELETE_ELEMENTS_N(def->nets, i,
+ def->nnets, 1));
break;
}
}
--
1.7.11.7