summaryrefslogtreecommitdiff
path: root/gdb/buildsym.h
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2022-04-07 08:06:50 -0400
committerSimon Marchi <simon.marchi@efficios.com>2022-04-12 14:13:10 -0400
commit71bc95ed2032567e2a7aebc3efe1c55a77abb7b2 (patch)
treedf72666a77b98bda029327e1acfc5b2366ebe766 /gdb/buildsym.h
parent30bf8e1ce4498467d62387b0d8a7009e3fbe2ab1 (diff)
downloadbinutils-gdb-71bc95ed2032567e2a7aebc3efe1c55a77abb7b2.tar.gz
gdb: allocate subfile with new
Allocate struct subfile with new, initialize its fields instead of memset-ing it to 0. Use a unique_ptr for the window after a subfile has been allocated but before it is linked in the buildsym_compunit's list of subfile (and therefore owned by the buildsym_compunit. I can't test the change in xcoffread.c, it's best-effort. I couldn't find where subfiles are freed in that file, I assume they were intentionally (or not) leaked. Change-Id: Ib3b6877de31b7e65bc466682f08dbf5840225f24
Diffstat (limited to 'gdb/buildsym.h')
-rw-r--r--gdb/buildsym.h22
1 files changed, 16 insertions, 6 deletions
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index 5f0e0230fd9..50ecd33d544 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -45,16 +45,26 @@ struct dynamic_prop;
struct subfile
{
- struct subfile *next;
+ subfile () = default;
+
+ /* There's nothing wrong with copying a subfile, but we don't need to, so use
+ this to avoid copying one by mistake. */
+ DISABLE_COPY_AND_ASSIGN (subfile);
+
+ struct subfile *next = nullptr;
+
/* Space for this is malloc'd. */
- char *name;
+ char *name = nullptr;
+
/* Space for this is malloc'd. */
- struct linetable *line_vector;
- int line_vector_length;
- enum language language;
- struct symtab *symtab;
+ struct linetable *line_vector = nullptr;
+ int line_vector_length = 0;
+ enum language language = language_unknown;
+ struct symtab *symtab = nullptr;
};
+using subfile_up = std::unique_ptr<subfile>;
+
/* Record the symbols defined for each context in a list. We don't
create a struct block for the context until we know how long to
make it. */