perf parse: Add a deep delete for parse event terms
Add a parse_events_term deep delete function so that owned strings and arrays are freed. Signed-off-by: Ian Rogers <irogers@google.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Andi Kleen <ak@linux.intel.com> Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: Jin Yao <yao.jin@linux.intel.com> Cc: John Garry <john.garry@huawei.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Martin KaFai Lau <kafai@fb.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Song Liu <songliubraving@fb.com> Cc: Stephane Eranian <eranian@google.com> Cc: Yonghong Song <yhs@fb.com> Cc: bpf@vger.kernel.org Cc: clang-built-linux@googlegroups.com Cc: netdev@vger.kernel.org Link: http://lore.kernel.org/lkml/20191030223448.12930-10-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:

committed by
Arnaldo Carvalho de Melo

parent
38f2c4226e
commit
1dc925568f
@@ -2812,6 +2812,18 @@ int parse_events_term__clone(struct parse_events_term **new,
|
||||
return new_term(new, &temp, str, 0);
|
||||
}
|
||||
|
||||
void parse_events_term__delete(struct parse_events_term *term)
|
||||
{
|
||||
if (term->array.nr_ranges)
|
||||
zfree(&term->array.ranges);
|
||||
|
||||
if (term->type_val != PARSE_EVENTS__TERM_TYPE_NUM)
|
||||
zfree(&term->val.str);
|
||||
|
||||
zfree(&term->config);
|
||||
free(term);
|
||||
}
|
||||
|
||||
int parse_events_copy_term_list(struct list_head *old,
|
||||
struct list_head **new)
|
||||
{
|
||||
@@ -2842,10 +2854,8 @@ void parse_events_terms__purge(struct list_head *terms)
|
||||
struct parse_events_term *term, *h;
|
||||
|
||||
list_for_each_entry_safe(term, h, terms, list) {
|
||||
if (term->array.nr_ranges)
|
||||
zfree(&term->array.ranges);
|
||||
list_del_init(&term->list);
|
||||
free(term);
|
||||
parse_events_term__delete(term);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user