[PATCH v2 2/8] Introduce virDomainInterfaceFree API

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

 



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

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 3ee6688..4199cd3 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -4612,6 +4612,8 @@ int virDomainInterfacesAddresses(virDomainPtr domain,
                                  unsigned int method,
                                  unsigned int flags);
 
+void virDomainInterfaceFree(virDomainInterfacePtr iface);
+
 /**
  * virSchedParameterType:
  *
diff --git a/python/generator.py b/python/generator.py
index ee39e51..e0a6f10 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 6f0de36..6f4ce60 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -20495,3 +20495,39 @@ error:
     virDispatchError(domain->conn);
     return -1;
 }
+
+/**
+ * virDomainInterfaceFree:
+ * @iface: array of interfaces
+ *
+ * Free an interface as returned by virDomainInterfacesAddresses.
+ * The @ifaces pointer is freed and should not be used thereafter.
+ * Basic usage is:
+ *
+ * virDomainInterfacePtr *iface = NULL;
+ * int i, j;
+ *
+ * i = virDomainInterfacesAddresses(dom, &iface, method, flags);
+ *
+ * Do something here ...;
+ *
+ * for (j = 0; j < i; j ++)
+ *   virDomainInterfaceFree(iface[j]);
+ * free(iface);
+ */
+void
+virDomainInterfaceFree(virDomainInterfacePtr iface)
+{
+    int i;
+    VIR_DEBUG("iface=%p", iface);
+
+
+    VIR_FREE(iface->name);
+    VIR_FREE(iface->hwaddr);
+    for (i = 0; i < iface->ip_addrs_count; i++) {
+        VIR_FREE(iface->ip_addrs[i].addr);
+        VIR_FREE(iface->ip_addrs[i].dstaddr);
+    }
+    VIR_FREE(iface->ip_addrs);
+    VIR_FREE(iface);
+}
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@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]