mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 01:34:11 +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:
parent
18c3321b8b
commit
660468b1a3
@ -239,11 +239,8 @@ virLogSetDefaultPriority(virLogPriority priority)
|
|||||||
static void
|
static void
|
||||||
virLogResetFilters(void)
|
virLogResetFilters(void)
|
||||||
{
|
{
|
||||||
size_t i;
|
virLogFilterListFree(virLogFilters, virLogNbFilters);
|
||||||
|
virLogFilters = NULL;
|
||||||
for (i = 0; i < virLogNbFilters; i++)
|
|
||||||
virLogFilterFree(virLogFilters[i]);
|
|
||||||
VIR_FREE(virLogFilters);
|
|
||||||
virLogNbFilters = 0;
|
virLogNbFilters = 0;
|
||||||
virLogFiltersSerial++;
|
virLogFiltersSerial++;
|
||||||
}
|
}
|
||||||
@ -259,6 +256,28 @@ virLogFilterFree(virLogFilterPtr filter)
|
|||||||
VIR_FREE(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:
|
* virLogDefineFilter:
|
||||||
* @match: the pattern to match
|
* @match: the pattern to match
|
||||||
|
@ -196,6 +196,7 @@ int virLogDefineOutput(virLogOutputFunc f,
|
|||||||
void virLogOutputFree(virLogOutputPtr output);
|
void virLogOutputFree(virLogOutputPtr output);
|
||||||
void virLogOutputListFree(virLogOutputPtr *list, int count);
|
void virLogOutputListFree(virLogOutputPtr *list, int count);
|
||||||
void virLogFilterFree(virLogFilterPtr filter);
|
void virLogFilterFree(virLogFilterPtr filter);
|
||||||
|
void virLogFilterListFree(virLogFilterPtr *list, int count);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Internal logging API
|
* Internal logging API
|
||||||
|
Loading…
Reference in New Issue
Block a user