Messages in this thread | | | Date | Thu, 3 Mar 2016 14:40:22 +0100 | From | Jiri Olsa <> | Subject | Re: [PATCH 2/8] perf tools: Introduce perf_hpp__setup_hists_formats() |
| |
On Thu, Mar 03, 2016 at 01:12:02AM +0900, Namhyung Kim wrote:
SNIP
> +struct perf_hpp_fmt *perf_hpp_fmt__copy(struct perf_hpp_fmt *fmt); > + > int hist_entry__filter(struct hist_entry *he, int type, const void *arg); > > static inline bool perf_hpp__should_skip(struct perf_hpp_fmt *format, > diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c > index 590ebf70e6da..29c75f0374c4 100644 > --- a/tools/perf/util/sort.c > +++ b/tools/perf/util/sort.c > @@ -1908,6 +1908,31 @@ __alloc_dynamic_entry(struct perf_evsel *evsel, struct format_field *field, > return hde; > } > > +struct perf_hpp_fmt *perf_hpp_fmt__copy(struct perf_hpp_fmt *fmt)
perf_hpp_fmt__dup might be better
> +{ > + struct perf_hpp_fmt *new_fmt = NULL; > + > + if (perf_hpp__is_sort_entry(fmt)) { > + struct hpp_sort_entry *hse, *new_hse; > + > + hse = container_of(fmt, struct hpp_sort_entry, hpp); > + new_hse = memdup(hse, sizeof(*hse)); > + if (new_hse) > + new_fmt = &new_hse->hpp; > + } else if (perf_hpp__is_dynamic_entry(fmt)) { > + struct hpp_dynamic_entry *hde, *new_hde; > + > + hde = container_of(fmt, struct hpp_dynamic_entry, hpp); > + new_hde = memdup(hde, sizeof(*hde)); > + if (new_hde) > + new_fmt = &new_hde->hpp; > + } else { > + new_fmt = memdup(fmt, sizeof(*fmt)); > + }
how about also initialize new_fmt's list and sort_list in here
could save some time in future if perf_hpp_fmt__copy is used in another place, which won't directly initialize them like you do in add_hierarchy_fmt
jirka
| |