This is just a free function for array of virDomainInterfacePtr as
returned by virDomainInterfacesAddresses API.
---
 include/libvirt/libvirt.h.in |  3 +++
 python/generator.py          |  1 +
 src/libvirt.c                | 31 +++++++++++++++++++++++++++++++
 src/libvirt_public.syms      |  1 +
 4 files changed, 36 insertions(+)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 3eb7ced..d40c4f8 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -4613,6 +4613,9 @@ int virDomainInterfacesAddresses(virDomainPtr domain,
                                  unsigned int method,
                                  unsigned int flags);
 
+void virDomainInterfaceFree(virDomainInterfacePtr ifaces,
+                            int count);
+
 /**
  * virSchedParameterType:
  *
diff --git a/python/generator.py b/python/generator.py
index e2f3134..1cc1e6e 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -430,6 +430,7 @@ skip_impl = (
     'virNodeSetMemoryParameters',
     'virNodeGetCPUMap',
     'virDomainInterfacesAddresses',
+    'virDomainInterfaceFree',
 )
 
 qemu_skip_impl = (
diff --git a/src/libvirt.c b/src/libvirt.c
index ad0f78c..3188257 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -20495,3 +20495,34 @@ error:
     virDispatchError(domain->conn);
     return -1;
 }
+
+/**
+ * virDomainInterfaceFree:
+ * @ifaces: array of interfaces
+ * @count: count of @ifaces items
+ *
+ * Free the array of interfaces as returned by virDomainInterfacesAddresses.
+ * The @ifaces pointer is freed and should not be used thereafter.
+ */
+void
+virDomainInterfaceFree(virDomainInterfacePtr ifaces,
+                       int count)
+{
+    int i, j;
+
+    VIR_DEBUG("ifaces=%p, count=%d", ifaces, count);
+
+    for (i = 0; i < count; i++) {
+        virDomainInterface tmp = ifaces[i];
+
+        VIR_FREE(tmp.name);
+        VIR_FREE(tmp.hwaddr);
+        for (j = 0; j < tmp.ip_addrs_count; j++) {
+            VIR_FREE(tmp.ip_addrs[j].addr);
+            VIR_FREE(tmp.ip_addrs[j].dstaddr);
+        }
+        VIR_FREE(tmp.ip_addrs);
+    }
+
+    VIR_FREE(ifaces);
+}
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 8e7c5d2..a401363 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -583,6 +583,7 @@ LIBVIRT_1.0.1 {
 LIBVIRT_1.0.2 {
     global:
         virDomainInterfacesAddresses;
+        virDomainInterfaceFree;
 } LIBVIRT_1.0.1;
 
 
-- 
1.8.0.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to