* check if cgrp is already defined, if so we reuse it
*/
evlist__for_each_entry(evlist, counter) {
- cgrp = counter->cgrp;
- if (!cgrp)
+ if (!counter->cgrp)
continue;
- if (!strcmp(cgrp->name, str)) {
- refcount_inc(&cgrp->refcnt);
+ if (!strcmp(counter->cgrp->name, str)) {
+ cgrp = cgroup__get(counter->cgrp);
break;
}
-
- cgrp = NULL;
}
if (!cgrp) {
}
}
+struct cgroup *cgroup__get(struct cgroup *cgroup)
+{
+ if (cgroup)
+ refcount_inc(&cgroup->refcnt);
+ return cgroup;
+}
+
int parse_cgroups(const struct option *opt, const char *str,
int unset __maybe_unused)
{
extern int nr_cgroups; /* number of explicit cgroups defined */
+struct cgroup *cgroup__get(struct cgroup *cgroup);
void cgroup__put(struct cgroup *cgroup);
int parse_cgroups(const struct option *opt, const char *str, int unset);