mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +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;
|
||||
virLogMessage;
|
||||
virLogOutputFree;
|
||||
virLogOutputListFree;
|
||||
virLogParseDefaultPriority;
|
||||
virLogParseFilters;
|
||||
virLogParseOutputs;
|
||||
|
@ -325,12 +325,8 @@ virLogDefineFilter(const char *match,
|
||||
static void
|
||||
virLogResetOutputs(void)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < virLogNbOutputs; i++)
|
||||
virLogOutputFree(virLogOutputs[i]);
|
||||
|
||||
VIR_FREE(virLogOutputs);
|
||||
virLogOutputListFree(virLogOutputs, virLogNbOutputs);
|
||||
virLogOutputs = NULL;
|
||||
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:
|
||||
* @f: the function to call to output a message
|
||||
|
@ -191,6 +191,7 @@ int virLogDefineOutput(virLogOutputFunc f,
|
||||
const char *name,
|
||||
unsigned int flags);
|
||||
void virLogOutputFree(virLogOutputPtr output);
|
||||
void virLogOutputListFree(virLogOutputPtr *list, int count);
|
||||
|
||||
/*
|
||||
* Internal logging API
|
||||
|
Loading…
Reference in New Issue
Block a user