perf annotate: Reuse path from the result of addr2line
authorNamhyung Kim <[email protected]>
Wed, 11 Sep 2013 05:09:26 +0000 (14:09 +0900)
committerArnaldo Carvalho de Melo <[email protected]>
Wed, 9 Oct 2013 18:58:20 +0000 (15:58 -0300)
In the symbol__get_source_line(), path and src_line->path will have same
value, but they were allocated separately, and leaks one.  Just share
path to src_line->path.

Signed-off-by: Namhyung Kim <[email protected]>
Reviewed-by: Jiri Olsa <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
tools/perf/util/annotate.c

index 7eae5488ecea47344cac10677104cb9e6cb2cc44..c6fd1870f278603f9a133ca76cc009a99459538e 100644 (file)
@@ -1143,11 +1143,7 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map,
                if (getline(&path, &line_len, fp) < 0 || !line_len)
                        goto next_close;
 
-               src_line->path = malloc(sizeof(char) * line_len + 1);
-               if (!src_line->path)
-                       goto next_close;
-
-               strcpy(src_line->path, path);
+               src_line->path = path;
                insert_source_line(&tmp_root, src_line);
 
        next_close: