mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 14:57:42 +00:00
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. Signed-off-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
057788c537
commit
4b48541249
@ -1823,6 +1823,7 @@ virLogGetOutputs;
|
|||||||
virLogLock;
|
virLogLock;
|
||||||
virLogMessage;
|
virLogMessage;
|
||||||
virLogOutputFree;
|
virLogOutputFree;
|
||||||
|
virLogOutputListFree;
|
||||||
virLogParseDefaultPriority;
|
virLogParseDefaultPriority;
|
||||||
virLogParseFilters;
|
virLogParseFilters;
|
||||||
virLogParseOutputs;
|
virLogParseOutputs;
|
||||||
|
@ -325,12 +325,8 @@ virLogDefineFilter(const char *match,
|
|||||||
static void
|
static void
|
||||||
virLogResetOutputs(void)
|
virLogResetOutputs(void)
|
||||||
{
|
{
|
||||||
size_t i;
|
virLogOutputListFree(virLogOutputs, virLogNbOutputs);
|
||||||
|
virLogOutputs = NULL;
|
||||||
for (i = 0; i < virLogNbOutputs; i++)
|
|
||||||
virLogOutputFree(virLogOutputs[i]);
|
|
||||||
|
|
||||||
VIR_FREE(virLogOutputs);
|
|
||||||
virLogNbOutputs = 0;
|
virLogNbOutputs = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,6 +344,28 @@ virLogOutputFree(virLogOutputPtr output)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* virLogDefineOutput:
|
* virLogDefineOutput:
|
||||||
* @f: the function to call to output a message
|
* @f: the function to call to output a message
|
||||||
|
@ -191,6 +191,7 @@ int virLogDefineOutput(virLogOutputFunc f,
|
|||||||
const char *name,
|
const char *name,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
void virLogOutputFree(virLogOutputPtr output);
|
void virLogOutputFree(virLogOutputPtr output);
|
||||||
|
void virLogOutputListFree(virLogOutputPtr *list, int count);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Internal logging API
|
* Internal logging API
|
||||||
|
Loading…
Reference in New Issue
Block a user