]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Do not allocate psymtabs via psymtab_storage
authorTom Tromey <tom@tromey.com>
Tue, 22 Oct 2019 22:51:55 +0000 (16:51 -0600)
committerTom Tromey <tom@tromey.com>
Sun, 26 Jan 2020 23:40:21 +0000 (16:40 -0700)
Currently, partial symbol tables are allocated by a method in
psymtab_storage.  However, eventually we want to subclass partial
symtabs in the symbol readers, so the calls to "new" will have to
happen there.  This patch is a first step, moving the allocation from
psymtab_storage and into allocate_psymtab.

gdb/ChangeLog
2020-01-26  Tom Tromey  <tom@tromey.com>

* psymtab.h (class psymtab_storage) <install_psymtab>: Rename from
allocate_psymtab.  Update documentation.
* psymtab.c (psymtab_storage::install_psymtab): Rename from
allocate_psymtab.  Do not use new.
(allocate_psymtab): Use new.  Update.

Change-Id: Iba6a9bf3ee1e78062fdb9f007c3010f826f64bc8

gdb/ChangeLog
gdb/psymtab.c
gdb/psymtab.h

index 345a81c935df05a2a0fa08ee78765443fce2383a..475ebbb116b3ea544fbb8bdb6dbf53c4ef9d5ce5 100644 (file)
@@ -1,3 +1,11 @@
+2020-01-26  Tom Tromey  <tom@tromey.com>
+
+       * psymtab.h (class psymtab_storage) <install_psymtab>: Rename from
+       allocate_psymtab.  Update documentation.
+       * psymtab.c (psymtab_storage::install_psymtab): Rename from
+       allocate_psymtab.  Do not use new.
+       (allocate_psymtab): Use new.  Update.
+
 2020-01-26  Tom Tromey  <tom@tromey.com>
 
        * xcoffread.c (xcoff_psymtab_to_symtab_1): Update.
index 037ed19182d1f95a246d56cb196af37f06e89acb..975737c559fcae96668aafeb47b4a5b9b1daba06 100644 (file)
@@ -75,15 +75,11 @@ psymtab_storage::~psymtab_storage ()
 
 /* See psymtab.h.  */
 
-struct partial_symtab *
-psymtab_storage::allocate_psymtab ()
+void
+psymtab_storage::install_psymtab (partial_symtab *pst)
 {
-  struct partial_symtab *psymtab = new struct partial_symtab;
-
-  psymtab->next = psymtabs;
-  psymtabs = psymtab;
-
-  return psymtab;
+  pst->next = psymtabs;
+  psymtabs = pst;
 }
 
 \f
@@ -1653,8 +1649,8 @@ init_psymbol_list (struct objfile *objfile, int total_symbols)
 struct partial_symtab *
 allocate_psymtab (const char *filename, struct objfile *objfile)
 {
-  struct partial_symtab *psymtab
-    = objfile->partial_symtabs->allocate_psymtab ();
+  struct partial_symtab *psymtab = new partial_symtab;
+  objfile->partial_symtabs->install_psymtab (psymtab);
 
   psymtab->filename
     = ((const char *) objfile->per_bfd->filename_cache.insert
index c0f0a97eb23837968a1af74782cefe2238615577..d66547418cb91c40c118b8bb2e174694051a6377 100644 (file)
@@ -83,11 +83,10 @@ public:
     return OBSTACK_CALLOC (obstack (), number, struct partial_symtab *);
   }
 
-  /* Allocate a new psymtab on the psymtab obstack.  The new psymtab
-     will be linked in to the "psymtabs" list, but otherwise all other
-     fields will be zero.  */
+  /* Install a psymtab on the psymtab list.  This transfers ownership
+     of PST to this object.  */
 
-  struct partial_symtab *allocate_psymtab ();
+  void install_psymtab (partial_symtab *pst);
 
   typedef next_adapter<struct partial_symtab> partial_symtab_range;