make symtab::dirname const
authorTom Tromey <tromey@redhat.com>
Mon, 25 Nov 2013 14:40:05 +0000 (07:40 -0700)
committerTom Tromey <tromey@redhat.com>
Fri, 6 Dec 2013 19:13:37 +0000 (12:13 -0700)
This makes symtab::dirname const and updates one spot to avoid an
intermediate constless result.

2013-12-06  Tom Tromey  <tromey@redhat.com>

* buildsym.c (end_symtab_from_static_block): Use obstack_copy0.
* symtab.h (struct symtab) <dirname>: Now const.

gdb/ChangeLog
gdb/buildsym.c
gdb/symtab.h

index 33366e2d8197f51caf2f12ee8ac1a8afc84c0087..9cec9c33b2fece8a491919ce34c3ba4545879911 100644 (file)
@@ -1,3 +1,8 @@
+2013-12-06  Tom Tromey  <tromey@redhat.com>
+
+       * buildsym.c (end_symtab_from_static_block): Use obstack_copy0.
+       * symtab.h (struct symtab) <dirname>: Now const.
+
 2013-12-06  Tom Tromey  <tromey@redhat.com>
 
        * symfile.c (allocate_symtab): Remove cast.
index 0326e264aba3e0e3a07fb5acb472da103842c2ae..8d9bdb1496618827be42b857d24e2a060c61db43 100644 (file)
@@ -1204,10 +1204,10 @@ end_symtab_from_static_block (struct block *static_block,
          if (subfile->dirname)
            {
              /* Reallocate the dirname on the symbol obstack.  */
-             symtab->dirname = (char *)
-               obstack_alloc (&objfile->objfile_obstack,
-                              strlen (subfile->dirname) + 1);
-             strcpy (symtab->dirname, subfile->dirname);
+             symtab->dirname =
+               obstack_copy0 (&objfile->objfile_obstack,
+                              subfile->dirname,
+                              strlen (subfile->dirname));
            }
          else
            {
index 821479ac7b6ee58ae5839f08adc2ca0217e42fc6..3be85cae7397817fef244ddf686788bca919caec 100644 (file)
@@ -879,7 +879,7 @@ struct symtab
 
   /* Directory in which it was compiled, or NULL if we don't know.  */
 
-  char *dirname;
+  const char *dirname;
 
   /* Total number of lines found in source file.  */