public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Fix a memory leak and remove an unused member
@ 2020-02-24 23:00 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2020-02-24 23:00 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4ac9383206032dd0357602136af1e05e7701142b
commit 4ac9383206032dd0357602136af1e05e7701142b
Author: Tom Tromey <tom@tromey.com>
Date: Mon Feb 24 15:50:57 2020 -0700
Fix a memory leak and remove an unused member
I noticed that setup_type_unit_groups leaks the symtab vector -- it
allocates this with XNEWVEC, but from what I can tell, nothing frees
it. This patch changes it to use XOBNEWVEC.
Also, the type_unit_unshareable::num_symtabs member is assigned but
never read. So, this removes it.
gdb/ChangeLog
2020-02-24 Tom Tromey <tom@tromey.com>
* dwarf2/read.h (struct type_unit_unshareable) <num_symtabs>:
Remove.
* dwarf2/read.c (dwarf2_cu::setup_type_unit_groups): Use
XOBNEWVEC.
Diff:
---
gdb/ChangeLog | 7 +++++++
gdb/dwarf2/read.c | 10 +++-------
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 2507b9c..1a15947 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
2020-02-24 Tom Tromey <tom@tromey.com>
+ * dwarf2/read.h (struct type_unit_unshareable) <num_symtabs>:
+ Remove.
+ * dwarf2/read.c (dwarf2_cu::setup_type_unit_groups): Use
+ XOBNEWVEC.
+
+2020-02-24 Tom Tromey <tom@tromey.com>
+
* dwarf2/read.h (struct dwarf2_per_cu_data) <type_unit_group_p>:
New method.
* dwarf2/read.c (IS_TYPE_UNIT_GROUP): Remove.
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 0f514ea..d97956e 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -589,10 +589,6 @@ struct type_unit_group
/* The data used to construct the hash key. */
struct stmt_list_hash hash;
- /* The number of symtabs from the line header.
- The value here must match line_header.num_file_names. */
- unsigned int num_symtabs;
-
/* The symbol tables for this TU (obtained from the files listed in
DW_AT_stmt_list).
WARNING: The order of entries here must match the order of entries
@@ -10854,9 +10850,9 @@ dwarf2_cu::setup_type_unit_groups (struct die_info *die)
process_full_type_unit still needs to know if this is the first
time. */
- tu_group->num_symtabs = line_header->file_names_size ();
- tu_group->symtabs = XNEWVEC (struct symtab *,
- line_header->file_names_size ());
+ tu_group->symtabs
+ = XOBNEWVEC (&COMPUNIT_OBJFILE (cust)->objfile_obstack,
+ struct symtab *, line_header->file_names_size ());
auto &file_names = line_header->file_names ();
for (i = 0; i < file_names.size (); ++i)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-02-24 23:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-24 23:00 [binutils-gdb] Fix a memory leak and remove an unused member Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).