On Thu, Apr 19, 2018 at 03:58:05PM +0200, Katerina Koukiou wrote:
virtDBusUtilStringListFree is an autoptr cleanup function
for gchar ** type.
Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
src/util.c | 9 +++++++++
src/util.h | 7 +++++++
2 files changed, 16 insertions(+)
diff --git a/src/util.c b/src/util.c
index b21f2c5..75f77e3 100644
--- a/src/util.c
+++ b/src/util.c
@@ -184,3 +184,12 @@ virtDBusUtilVirNetworkListFree(virNetworkPtr *networks)
g_free(networks);
}
+
+void
+virtDBusUtilStringListFree(GCharArray *item)
+{
+ for (gint i = 0; item[i] != NULL; i += 1)
i++, please
+ g_free(item[i]);
+
+ g_free(item);
+}
diff --git a/src/util.h b/src/util.h
index 5141172..7ae4705 100644
--- a/src/util.h
+++ b/src/util.h
@@ -82,3 +82,10 @@ virtDBusUtilVirNetworkListFree(virNetworkPtr *networks);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virNetwork, virNetworkFree);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virNetworkPtr, virtDBusUtilVirNetworkListFree);
+
+typedef gchar *GCharArray;
+
This is the naming convention used by glib,
custom types should use the virtDBus prefix.
Jano
+void
+virtDBusUtilStringListFree(GCharArray *item);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GCharArray, virtDBusUtilStringListFree);
--
2.15.0
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list