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. --- src/util/virlog.c | 20 ++++++++++++++++++++ src/util/virlog.h | 1 + 2 files changed, 21 insertions(+) diff --git a/src/util/virlog.c b/src/util/virlog.c index 36fecda..a1f5872 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -1630,3 +1630,23 @@ virLogFilterFree(virLogFilterPtr filter) VIR_FREE(filter->match); 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); +} diff --git a/src/util/virlog.h b/src/util/virlog.h index eec3a5d..eca7894 100644 --- a/src/util/virlog.h +++ b/src/util/virlog.h @@ -198,6 +198,7 @@ extern int virLogOutputNew(virLogOutputFunc f, extern void virLogOutputFree(virLogOutputPtr output); extern void virLogFilterFree(virLogFilterPtr filter); extern void virLogOutputListFree(virLogOutputPtr *list, int count); +extern void virLogFilterListFree(virLogFilterPtr *list, int count); /* * Internal logging API -- 2.4.11 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list