aboutsummaryrefslogtreecommitdiff
path: root/gdb/psymtab.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-10-16 14:06:43 -0600
committerTom Tromey <tom@tromey.com>2020-01-26 16:40:20 -0700
commit6f17252b76dbe8bedd32b6df6ce52af707bfb04b (patch)
tree57515b3759448d0f1ab318cb89233e3e82ca553b /gdb/psymtab.c
parentf6f1cebcbe4dd33cdd65094267cc33395d55ece7 (diff)
downloadgdb-6f17252b76dbe8bedd32b6df6ce52af707bfb04b.zip
gdb-6f17252b76dbe8bedd32b6df6ce52af707bfb04b.tar.gz
gdb-6f17252b76dbe8bedd32b6df6ce52af707bfb04b.tar.bz2
Use new and delete for psymtabs
This changes psymtabs to be allocated with new and destroyed with delete. As a consequence, the psymtab free-list is also removed. The motivation for this is to let symbol readers subclass partial_symtab. gdb/ChangeLog 2020-01-26 Tom Tromey <tom@tromey.com> * mdebugread.c (parse_partial_symbols): Use discard_psymtab. * psymtab.h (class psymtab_storage) <free_psymtabs>: Remove. * psymtab.c (psymtab_storage): Delete psymtabs. (psymtab_storage::allocate_psymtab): Use new. (psymtab_storage::discard_psymtab): Use delete. * psympriv.h (struct partial_symtab): Add constructor and initializers. Change-Id: I4e78ac538fc0ea52b57489c1afb8f935a30941ef
Diffstat (limited to 'gdb/psymtab.c')
-rw-r--r--gdb/psymtab.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 18580f5..5f42867 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -64,6 +64,13 @@ psymtab_storage::psymtab_storage ()
psymtab_storage::~psymtab_storage ()
{
+ partial_symtab *iter = psymtabs;
+ while (iter != nullptr)
+ {
+ partial_symtab *next = iter->next;
+ delete iter;
+ iter = next;
+ }
}
/* See psymtab.h. */
@@ -71,17 +78,7 @@ psymtab_storage::~psymtab_storage ()
struct partial_symtab *
psymtab_storage::allocate_psymtab ()
{
- struct partial_symtab *psymtab;
-
- if (free_psymtabs != nullptr)
- {
- psymtab = free_psymtabs;
- free_psymtabs = psymtab->next;
- }
- else
- psymtab = XOBNEW (obstack (), struct partial_symtab);
-
- memset (psymtab, 0, sizeof (struct partial_symtab));
+ struct partial_symtab *psymtab = new struct partial_symtab;
psymtab->next = psymtabs;
psymtabs = psymtab;
@@ -1705,11 +1702,7 @@ psymtab_storage::discard_psymtab (struct partial_symtab *pst)
while ((*prev_pst) != pst)
prev_pst = &((*prev_pst)->next);
(*prev_pst) = pst->next;
-
- /* Next, put it on a free list for recycling. */
-
- pst->next = free_psymtabs;
- free_psymtabs = pst;
+ delete pst;
}