1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-23 21:34:54 +03:00

virlog: Introduce virLogFilterListFree

This is just a convenience method for discarding a list of filters 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:
Erik Skultety 2016-03-29 22:07:23 +02:00
parent 18c3321b8b
commit 660468b1a3
2 changed files with 25 additions and 5 deletions

View File

@ -239,11 +239,8 @@ virLogSetDefaultPriority(virLogPriority priority)
static void
virLogResetFilters(void)
{
size_t i;
for (i = 0; i < virLogNbFilters; i++)
virLogFilterFree(virLogFilters[i]);
VIR_FREE(virLogFilters);
virLogFilterListFree(virLogFilters, virLogNbFilters);
virLogFilters = NULL;
virLogNbFilters = 0;
virLogFiltersSerial++;
}
@ -259,6 +256,28 @@ virLogFilterFree(virLogFilterPtr filter)
VIR_FREE(filter);
}
/**
* virLogFilterFreeList:
* @list: list of filters to be freed
* @count: number of elements in the list
*
* Frees a list of filters.
*/
void
virLogFilterListFree(virLogFilterPtr *list, int count)
{
size_t i;
if (!list || count < 0)
return;
for (i = 0; i < count; i++)
virLogFilterFree(list[i]);
VIR_FREE(list);
}
/**
* virLogDefineFilter:
* @match: the pattern to match

View File

@ -196,6 +196,7 @@ int virLogDefineOutput(virLogOutputFunc f,
void virLogOutputFree(virLogOutputPtr output);
void virLogOutputListFree(virLogOutputPtr *list, int count);
void virLogFilterFree(virLogFilterPtr filter);
void virLogFilterListFree(virLogFilterPtr *list, int count);
/*
* Internal logging API