diff options
Diffstat (limited to 'gprof/utils.c')
-rw-r--r-- | gprof/utils.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/gprof/utils.c b/gprof/utils.c index 76bc57d..2c04895 100644 --- a/gprof/utils.c +++ b/gprof/utils.c @@ -43,9 +43,7 @@ int print_name_only (Sym *self) { const char *name = self->name; - const char *filename; char *demangled = 0; - char buf[PATH_MAX]; int size = 0; if (name) @@ -60,7 +58,9 @@ print_name_only (Sym *self) size = strlen (name); if ((line_granularity || inline_file_names) && self->file) { - filename = self->file->name; + const char *filename = self->file->name; + char *buf; + if (!print_path) { filename = strrchr (filename, '/'); @@ -73,6 +73,7 @@ print_name_only (Sym *self) filename = self->file->name; } } + buf = xmalloc (strlen (filename) + 8 + 20 + 16); if (line_granularity) { sprintf (buf, " (%s:%d @ %lx)", filename, self->line_num, @@ -84,6 +85,7 @@ print_name_only (Sym *self) } printf ("%s", buf); size += strlen (buf); + free (buf); } free (demangled); DBG (DFNDEBUG, printf ("{%d} ", self->cg.top_order)); |