]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gprof/utils.c
PR27716, build failure for msdosdjgpp: PATH_MAX undeclared
[thirdparty/binutils-gdb.git] / gprof / utils.c
index 76bc57d31831994d696795b58cf5fb8e1cce51b3..2c0489540dc16c0461f04543e977dead3a31ed83 100644 (file)
@@ -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));