[PATCH 13/32] perf tools: Use zfree() instead of ad hoc equivalent

From: Arnaldo Carvalho de Melo
Date: Thu Feb 09 2017 - 21:46:46 EST


From: Taeung Song <treeze.taeung@xxxxxxxxx>

We have zfree(&ptr) for this very common pattern:

free(ptr);
ptr = NULL;

So use it in a few more places.

Signed-off-by: Taeung Song <treeze.taeung@xxxxxxxxx>
Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Wang Nan <wangnan0@xxxxxxxxxx>
Link: http://lkml.kernel.org/r/1485952447-7013-4-git-send-email-treeze.taeung@xxxxxxxxx
[ rewrote commit log ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>

Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
tools/perf/util/parse-events.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 1f1f77d8d3ab..ab1ba22d879a 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -254,8 +254,7 @@ struct tracepoint_path *tracepoint_name_to_path(const char *name)
if (path->system == NULL || path->name == NULL) {
zfree(&path->system);
zfree(&path->name);
- free(path);
- path = NULL;
+ zfree(&path);
}

return path;
@@ -1482,8 +1481,7 @@ static void perf_pmu__parse_cleanup(void)
p = perf_pmu_events_list + i;
free(p->symbol);
}
- free(perf_pmu_events_list);
- perf_pmu_events_list = NULL;
+ zfree(&perf_pmu_events_list);
perf_pmu_events_list_num = 0;
}
}
--
2.9.3