Commit 58a98c9c authored by Adrian Hunter's avatar Adrian Hunter Committed by Arnaldo Carvalho de Melo

perf symbols: Remove open coded management of short_name_allocated member

Instead of expecting callers to set this member accodingly so that later
at dso destruction it can, if needed, be correctly free()d, make it a
requirement by passing it as a parameter to dso__set_short_name.

Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
CC: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Link: http://lkml.kernel.org/r/52A707A2.5020802@intel.com
[ Renamed the 'allocated' parameter to clearly indicate to which variable it refers to. ]
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 7521ab59
...@@ -379,7 +379,7 @@ struct dso *dso__kernel_findnew(struct machine *machine, const char *name, ...@@ -379,7 +379,7 @@ struct dso *dso__kernel_findnew(struct machine *machine, const char *name,
* processing we had no idea this was the kernel dso. * processing we had no idea this was the kernel dso.
*/ */
if (dso != NULL) { if (dso != NULL) {
dso__set_short_name(dso, short_name); dso__set_short_name(dso, short_name, false);
dso->kernel = dso_type; dso->kernel = dso_type;
} }
...@@ -394,17 +394,22 @@ void dso__set_long_name(struct dso *dso, char *name) ...@@ -394,17 +394,22 @@ void dso__set_long_name(struct dso *dso, char *name)
dso->long_name_len = strlen(name); dso->long_name_len = strlen(name);
} }
void dso__set_short_name(struct dso *dso, const char *name) void dso__set_short_name(struct dso *dso, const char *name, bool name_allocated)
{ {
if (name == NULL) if (name == NULL)
return; return;
dso->short_name = name;
dso->short_name_len = strlen(name); if (dso->short_name_allocated)
free((char *)dso->short_name);
dso->short_name = name;
dso->short_name_len = strlen(name);
dso->short_name_allocated = name_allocated;
} }
static void dso__set_basename(struct dso *dso) static void dso__set_basename(struct dso *dso)
{ {
dso__set_short_name(dso, basename(dso->long_name)); dso__set_short_name(dso, basename(dso->long_name), false);
} }
int dso__name_len(const struct dso *dso) int dso__name_len(const struct dso *dso)
...@@ -440,7 +445,7 @@ struct dso *dso__new(const char *name) ...@@ -440,7 +445,7 @@ struct dso *dso__new(const char *name)
int i; int i;
strcpy(dso->name, name); strcpy(dso->name, name);
dso__set_long_name(dso, dso->name); dso__set_long_name(dso, dso->name);
dso__set_short_name(dso, dso->name); dso__set_short_name(dso, dso->name, false);
for (i = 0; i < MAP__NR_TYPES; ++i) for (i = 0; i < MAP__NR_TYPES; ++i)
dso->symbols[i] = dso->symbol_names[i] = RB_ROOT; dso->symbols[i] = dso->symbol_names[i] = RB_ROOT;
dso->cache = RB_ROOT; dso->cache = RB_ROOT;
......
...@@ -110,7 +110,7 @@ static inline void dso__set_loaded(struct dso *dso, enum map_type type) ...@@ -110,7 +110,7 @@ static inline void dso__set_loaded(struct dso *dso, enum map_type type)
struct dso *dso__new(const char *name); struct dso *dso__new(const char *name);
void dso__delete(struct dso *dso); void dso__delete(struct dso *dso);
void dso__set_short_name(struct dso *dso, const char *name); void dso__set_short_name(struct dso *dso, const char *name, bool name_allocated);
void dso__set_long_name(struct dso *dso, char *name); void dso__set_long_name(struct dso *dso, char *name);
int dso__name_len(const struct dso *dso); int dso__name_len(const struct dso *dso);
......
...@@ -935,8 +935,7 @@ static int machine__process_kernel_mmap_event(struct machine *machine, ...@@ -935,8 +935,7 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
if (name == NULL) if (name == NULL)
goto out_problem; goto out_problem;
dso__set_short_name(map->dso, name); dso__set_short_name(map->dso, name, true);
map->dso->short_name_allocated = 1;
map->end = map->start + event->mmap.len; map->end = map->start + event->mmap.len;
} else if (is_kernel_mmap) { } else if (is_kernel_mmap) {
const char *symbol_name = (event->mmap.filename + const char *symbol_name = (event->mmap.filename +
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment