This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 2/8] make symtab::dirname const


This makes symtab::dirname const and updates one spot to avoid an
intermediate constless result.

2013-11-26  Tom Tromey  <tromey@redhat.com>

	* buildsym.c (end_symtab_from_static_block): Use obstack_copy0.
	* symtab.h (struct symtab) <dirname>: Now const.
---
 gdb/ChangeLog  | 5 +++++
 gdb/buildsym.c | 8 ++++----
 gdb/symtab.h   | 2 +-
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 0326e26..8d9bdb1 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -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
 	    {
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 821479a..3be85ca 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -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.  */
 
-- 
1.8.1.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]