diff options
author | Ian Rogers <[email protected]> | 2023-03-11 18:15:39 -0800 |
---|---|---|
committer | Arnaldo Carvalho de Melo <[email protected]> | 2023-03-13 17:42:26 -0300 |
commit | 4bb311b29e82c795340a6e4a5db83d8ccbe2dc49 (patch) | |
tree | 4b4b2559ea22f74c1ff6de65f692ae1bcb04e754 | |
parent | 7abf0bccaaec77043358ee07e694d31cf9a7dd76 (diff) |
perf parse-events: Pass ownership of the group name
Pass ownership of the group name rather than copying and freeing the
original. This saves a memory allocation and copy.
Signed-off-by: Ian Rogers <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Florian Fischer <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: James Clark <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: John Garry <[email protected]>
Cc: Kajol Jain <[email protected]>
Cc: Kan Liang <[email protected]>
Cc: Kim Phillips <[email protected]>
Cc: Leo Yan <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Ravi Bangoria <[email protected]>
Cc: Sean Christopherson <[email protected]>
Cc: Steinar H. Gunderson <[email protected]>
Cc: Stephane Eranian <[email protected]>
Cc: Suzuki Poulouse <[email protected]>
Cc: Xing Zhengjun <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
-rw-r--r-- | tools/perf/util/parse-events.c | 3 | ||||
-rw-r--r-- | tools/perf/util/parse-events.y | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 0336ff27c15f..1be454697d57 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -1761,6 +1761,7 @@ parse_events__set_leader_for_uncore_aliase(char *name, struct list_head *list, handled: ret = 1; + free(name); out: free(leaders); return ret; @@ -1786,7 +1787,7 @@ void parse_events__set_leader(char *name, struct list_head *list, leader = arch_evlist__leader(list); __perf_evlist__set_leader(list, &leader->core); - leader->group_name = name ? strdup(name) : NULL; + leader->group_name = name; list_move(&leader->core.node, list); } diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y index be8c51770051..541b8dde2063 100644 --- a/tools/perf/util/parse-events.y +++ b/tools/perf/util/parse-events.y @@ -202,8 +202,8 @@ PE_NAME '{' events '}' struct list_head *list = $3; inc_group_count(list, _parse_state); + /* Takes ownership of $1. */ parse_events__set_leader($1, list, _parse_state); - free($1); $$ = list; } | |