diff options
author | Tom Tromey <tom@tromey.com> | 2017-11-03 14:55:39 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-11-08 11:20:14 -0700 |
commit | 2f4732b0e622d9d5d899c29e2132e4cd2966aaad (patch) | |
tree | 436c8e4f7e095462880acf142f387d942aec206b /gdb/dwarf2read.c | |
parent | f9d67a22392f8f52c779f68a2561eb35c2f86b81 (diff) | |
download | gdb-2f4732b0e622d9d5d899c29e2132e4cd2966aaad.zip gdb-2f4732b0e622d9d5d899c29e2132e4cd2966aaad.tar.gz gdb-2f4732b0e622d9d5d899c29e2132e4cd2966aaad.tar.bz2 |
Remove symbolp vector
This removes the symbolp typedef from dwarf2read.c and converts the
associated VEC uses to std::vector. This fixes a latent possible
memory leak if an exception were thrown, because there were no
cleanups installed for these VECs.
Regression tested on the buildbot.
gdb/ChangeLog
2017-11-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (symbolp): Remove typedef.
(read_func_scope): Use std::vector.
(process_structure_scope): Use std::vector.
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r-- | gdb/dwarf2read.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 389d8f7..b6bd291 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -83,9 +83,6 @@ #include <unordered_map> #include "selftest.h" -typedef struct symbol *symbolp; -DEF_VEC_P (symbolp); - /* When == 1, print basic high level tracing messages. When > 1, be more verbose. This is in contrast to the low level DIE reading of dwarf_die_debug. */ @@ -12204,7 +12201,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) CORE_ADDR baseaddr; struct block *block; int inlined_func = (die->tag == DW_TAG_inlined_subroutine); - VEC (symbolp) *template_args = NULL; + std::vector<struct symbol *> template_args; struct template_symbol *templ_func = NULL; if (inlined_func) @@ -12297,7 +12294,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) struct symbol *arg = new_symbol (child_die, NULL, cu); if (arg != NULL) - VEC_safe_push (symbolp, template_args, arg); + template_args.push_back (arg); } else process_die (child_die, cu); @@ -12352,18 +12349,17 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) gdbarch_make_symbol_special (gdbarch, newobj->name, objfile); /* Attach template arguments to function. */ - if (! VEC_empty (symbolp, template_args)) + if (!template_args.empty ()) { gdb_assert (templ_func != NULL); - templ_func->n_template_arguments = VEC_length (symbolp, template_args); + templ_func->n_template_arguments = template_args.size (); templ_func->template_arguments = XOBNEWVEC (&objfile->objfile_obstack, struct symbol *, templ_func->n_template_arguments); memcpy (templ_func->template_arguments, - VEC_address (symbolp, template_args), + template_args.data (), (templ_func->n_template_arguments * sizeof (struct symbol *))); - VEC_free (symbolp, template_args); } /* In C++, we can have functions nested inside functions (e.g., when @@ -14314,7 +14310,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) if (die->child != NULL && ! die_is_declaration (die, cu)) { struct field_info fi; - VEC (symbolp) *template_args = NULL; + std::vector<struct symbol *> template_args; struct cleanup *back_to = make_cleanup (null_cleanup, 0); memset (&fi, 0, sizeof (struct field_info)); @@ -14359,27 +14355,25 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) struct symbol *arg = new_symbol (child_die, NULL, cu); if (arg != NULL) - VEC_safe_push (symbolp, template_args, arg); + template_args.push_back (arg); } child_die = sibling_die (child_die); } /* Attach template arguments to type. */ - if (! VEC_empty (symbolp, template_args)) + if (!template_args.empty ()) { ALLOCATE_CPLUS_STRUCT_TYPE (type); - TYPE_N_TEMPLATE_ARGUMENTS (type) - = VEC_length (symbolp, template_args); + TYPE_N_TEMPLATE_ARGUMENTS (type) = template_args.size (); TYPE_TEMPLATE_ARGUMENTS (type) = XOBNEWVEC (&objfile->objfile_obstack, struct symbol *, TYPE_N_TEMPLATE_ARGUMENTS (type)); memcpy (TYPE_TEMPLATE_ARGUMENTS (type), - VEC_address (symbolp, template_args), + template_args.data (), (TYPE_N_TEMPLATE_ARGUMENTS (type) * sizeof (struct symbol *))); - VEC_free (symbolp, template_args); } /* Attach fields and member functions to the type. */ |