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

[libvirt] [PATCH 16/38] virlog: Introduce virLogOutputListFree



This is just a convenience method for discarding a list of outputs instead of
using a 'for' loop everywhere. It is safe to pass -1 as the number of elements
in the list as well as passing NULL as list reference.
---
 src/libvirt_private.syms |  1 +
 src/util/virlog.c        | 20 ++++++++++++++++++++
 src/util/virlog.h        |  1 +
 3 files changed, 22 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 433cf60..e594eaa 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1752,6 +1752,7 @@ virLogGetOutputs;
 virLogLock;
 virLogMessage;
 virLogOutputFree;
+virLogOutputListFree;
 virLogOutputNew;
 virLogParseDefaultPriority;
 virLogParseFilters;
diff --git a/src/util/virlog.c b/src/util/virlog.c
index e36ff73..5da1af7 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -1600,3 +1600,23 @@ virLogDefineFilters(virLogFilterPtr *filters, size_t nfilters)
 
     return virLogNbFilters;
 }
+
+/**
+ * virLogOutputsFreeList:
+ * @list: list of outputs to be freed
+ * @count: number of elements in the list
+ *
+ * Frees a list of outputs.
+ */
+void
+virLogOutputListFree(virLogOutputPtr *list, int count)
+{
+    size_t i;
+
+    if (!list || count < 0)
+        return;
+
+    for (i = 0; i < count; i++)
+        virLogOutputFree(list[i]);
+    VIR_FREE(list);
+}
diff --git a/src/util/virlog.h b/src/util/virlog.h
index 7573984..4f0eea7 100644
--- a/src/util/virlog.h
+++ b/src/util/virlog.h
@@ -196,6 +196,7 @@ extern int virLogOutputNew(virLogOutputFunc f,
                            const char *name,
                            unsigned int flags);
 extern void virLogOutputFree(virLogOutputPtr output);
+extern void virLogOutputListFree(virLogOutputPtr *list, int count);
 
 /*
  * Internal logging API
-- 
2.4.3


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