From 2f9d0898a306b35bed28eb1b455db7a69f058b5b Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Tue, 16 Feb 2010 21:30:41 -0500 Subject: parse-events: Add pevent_filter_reset() Add function pevent_filter_reset() to reset and clear all filters in an event_filter structure. Signed-off-by: Steven Rostedt --- parse-events.h | 2 ++ parse-filter.c | 20 +++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/parse-events.h b/parse-events.h index 8e42947..13b1f3a 100644 --- a/parse-events.h +++ b/parse-events.h @@ -589,6 +589,8 @@ int pevent_filter_match(struct event_filter *filter, int pevent_event_filtered(struct event_filter *filter, int event_id); +void pevent_filter_reset(struct event_filter *filter); + void pevent_filter_free(struct event_filter *filter); #endif /* _PARSE_EVENTS_H */ diff --git a/parse-filter.c b/parse-filter.c index 98c31dd..1627b96 100644 --- a/parse-filter.c +++ b/parse-filter.c @@ -808,16 +808,30 @@ int pevent_filter_remove_event(struct event_filter *filter, return 1; } -void pevent_filter_free(struct event_filter *filter) +/** + * pevent_filter_reset - clear all filters in a filter + * @filter: the event filter to reset + * + * Removes all filters from a filter and resets it. + */ +void pevent_filter_reset(struct event_filter *filter) { int i; - pevent_unref(filter->pevent); - for (i = 0; i < filter->filters; i++) free_filter_type(&filter->event_filters[i]); free(filter->event_filters); + filter->filters = 0; + filter->event_filters = NULL; +} + +void pevent_filter_free(struct event_filter *filter) +{ + pevent_unref(filter->pevent); + + pevent_filter_reset(filter); + free(filter); } -- cgit v1.2.2