[PATCH 1/4] conf: storage: Introduce virStoragePoolSourceListFree

Peter Krempa pkrempa at redhat.com
Fri Jun 18 13:04:46 UTC 2021


Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/conf/storage_conf.c  | 16 ++++++++++++++++
 src/conf/storage_conf.h  |  5 +++++
 src/libvirt_private.syms |  1 +
 3 files changed, 22 insertions(+)

diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 0ecdb0969a..2aa9a3d8f9 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1803,3 +1803,19 @@ virStoragePoolSourceListFormat(virStoragePoolSourceList *def)

     return virBufferContentAndReset(&buf);
 }
+
+
+void
+virStoragePoolSourceListFree(virStoragePoolSourceList *list)
+{
+    size_t i;
+
+    if (!list)
+        return;
+
+    for (i = 0; i < list->nsources; i++)
+        virStoragePoolSourceClear(&list->sources[i]);
+
+    g_free(list->sources);
+    g_free(list);
+}
diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
index 345026aa37..76efaac531 100644
--- a/src/conf/storage_conf.h
+++ b/src/conf/storage_conf.h
@@ -266,6 +266,11 @@ struct _virStoragePoolSourceList {
     virStoragePoolSource *sources;
 };

+void
+virStoragePoolSourceListFree(virStoragePoolSourceList *list);
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(virStoragePoolSourceList, virStoragePoolSourceListFree);
+
+
 virStoragePoolDef *
 virStoragePoolDefParseXML(xmlXPathContextPtr ctxt);

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 2efa787664..68e4b6aab8 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1048,6 +1048,7 @@ virStoragePoolSourceClear;
 virStoragePoolSourceDeviceClear;
 virStoragePoolSourceFree;
 virStoragePoolSourceListFormat;
+virStoragePoolSourceListFree;
 virStoragePoolSourceListNewSource;
 virStoragePoolTypeFromString;
 virStoragePoolTypeToString;
-- 
2.31.1




More information about the libvir-list mailing list