Add a complementary method to virLogOutputNew.
---
src/libvirt_private.syms | 1 +
src/util/virlog.c | 21 ++++++++++++++++-----
src/util/virlog.h | 1 +
3 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index fac361b..433cf60 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1751,6 +1751,7 @@ virLogGetNbOutputs;
virLogGetOutputs;
virLogLock;
virLogMessage;
+virLogOutputFree;
virLogOutputNew;
virLogParseDefaultPriority;
virLogParseFilters;
diff --git a/src/util/virlog.c b/src/util/virlog.c
index e101484..e36ff73 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -323,16 +323,27 @@ virLogResetOutputs(void)
{
size_t i;
- for (i = 0; i < virLogNbOutputs; i++) {
- if (virLogOutputs[i]->c != NULL)
- virLogOutputs[i]->c(virLogOutputs[i]->data);
- VIR_FREE(virLogOutputs[i]->name);
- }
+ for (i = 0; i < virLogNbOutputs; i++)
+ virLogOutputFree(virLogOutputs[i]);
+
VIR_FREE(virLogOutputs);
virLogNbOutputs = 0;
}
+void
+virLogOutputFree(virLogOutputPtr output)
+{
+ if (!output)
+ return;
+
+ if (output->c)
+ output->c(output->data);
+ VIR_FREE(output->name);
+ VIR_FREE(output);
+
+}
+
/**
* virLogOutputNew:
* @f: the function to call to output a message
diff --git a/src/util/virlog.h b/src/util/virlog.h
index 93456db..7573984 100644
--- a/src/util/virlog.h
+++ b/src/util/virlog.h
@@ -195,6 +195,7 @@ extern int virLogOutputNew(virLogOutputFunc f,
virLogDestination dest,
const char *name,
unsigned int flags);
+extern void virLogOutputFree(virLogOutputPtr output);
/*
* Internal logging API
--
2.4.3