summaryrefslogtreecommitdiff
path: root/tools/perf/util/cgroup.h
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2018-03-06 15:53:22 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-03-07 10:22:26 -0300
commit3b5692864da3a8dec95d8c757147f436d19f8ff7 (patch)
tree03172f4f90dbfe5145a6196d84edbba33557fd1b /tools/perf/util/cgroup.h
parent483322dda03a7ad807e82f9c25fac315a4eee1c5 (diff)
perf cgroup: Make the cgroup name be const char *
The usual thing is for a constructor to allocate space for its members, not to require that the caller pass a pre-allocated 'name' and then, at its destructor, to free something not allocated by it. Fix it by making cgroup__new() to receive a const char pointer, then allocate cgroup->name that then can continue to be freed at cgroup__delete(), balancing the alloc/free operations inside the cgroup struct methods. This eases calling evlist__findnew_cgroup() from the custom 'perf trace' cgroup parser, that will only call parse_cgroups() when the '-G cgroup' is passed on the command line after '-e event' entries, when it'll behave just like 'perf stat' and 'perf record', i.e. the previous parse_cgroup() users that mandate that -G only can come after a -e. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Stephane Eranian <eranian@google.com> Cc: Wang Nan <wangnan0@huawei.com> Link: https://lkml.kernel.org/n/tip-4leugnuyqi10t98990o3xi1t@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/cgroup.h')
-rw-r--r--tools/perf/util/cgroup.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/perf/util/cgroup.h b/tools/perf/util/cgroup.h
index b213f5e9a3ed..f033a80c1b14 100644
--- a/tools/perf/util/cgroup.h
+++ b/tools/perf/util/cgroup.h
@@ -20,7 +20,7 @@ void cgroup__put(struct cgroup *cgroup);
struct perf_evlist;
-struct cgroup *evlist__findnew_cgroup(struct perf_evlist *evlist, char *name);
+struct cgroup *evlist__findnew_cgroup(struct perf_evlist *evlist, const char *name);
void evlist__set_default_cgroup(struct perf_evlist *evlist, struct cgroup *cgroup);