diff options
author | Simon Marchi <simon.marchi@ericsson.com> | 2017-10-11 09:34:08 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@ericsson.com> | 2017-10-11 09:34:08 -0400 |
commit | 905014d7205d4f171c5cabf695fe1ec3da9b33d3 (patch) | |
tree | 354b31d58b64b60cdfee181a8b6556892628103b /gdb/symfile.c | |
parent | 56d704daee44b036d1eff86123de6dec0c55f61b (diff) | |
download | gdb-905014d7205d4f171c5cabf695fe1ec3da9b33d3.zip gdb-905014d7205d4f171c5cabf695fe1ec3da9b33d3.tar.gz gdb-905014d7205d4f171c5cabf695fe1ec3da9b33d3.tar.bz2 |
Use std::vector for symtab_fns
Simple replacement of VEC with std::vector.
gdb/ChangeLog:
* symfile.c (registered_sym_fns): Make struct, not typedef.
(DEF_VEC_O (registered_sym_fns)): Remove.
(symtab_fns): Change type to std::vector.
(add_symtab_fns): Adjust.
(find_sym_fns): Adjust.
Diffstat (limited to 'gdb/symfile.c')
-rw-r--r-- | gdb/symfile.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/gdb/symfile.c b/gdb/symfile.c index a741654..b4abe84 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -111,18 +111,20 @@ static void symfile_find_segment_sections (struct objfile *objfile); calls add_symtab_fns() to register information on each format it is prepared to read. */ -typedef struct +struct registered_sym_fns { + registered_sym_fns (bfd_flavour sym_flavour_, const struct sym_fns *sym_fns_) + : sym_flavour (sym_flavour_), sym_fns (sym_fns_) + {} + /* BFD flavour that we handle. */ enum bfd_flavour sym_flavour; /* The "vtable" of symbol functions. */ const struct sym_fns *sym_fns; -} registered_sym_fns; - -DEF_VEC_O (registered_sym_fns); +}; -static VEC (registered_sym_fns) *symtab_fns = NULL; +static std::vector<registered_sym_fns> symtab_fns; /* Values for "set print symbol-loading". */ @@ -1768,9 +1770,7 @@ get_section_index (struct objfile *objfile, const char *section_name) void add_symtab_fns (enum bfd_flavour flavour, const struct sym_fns *sf) { - registered_sym_fns fns = { flavour, sf }; - - VEC_safe_push (registered_sym_fns, symtab_fns, &fns); + symtab_fns.emplace_back (flavour, sf); } /* Initialize OBJFILE to read symbols from its associated BFD. It @@ -1781,18 +1781,16 @@ add_symtab_fns (enum bfd_flavour flavour, const struct sym_fns *sf) static const struct sym_fns * find_sym_fns (bfd *abfd) { - registered_sym_fns *rsf; enum bfd_flavour our_flavour = bfd_get_flavour (abfd); - int i; if (our_flavour == bfd_target_srec_flavour || our_flavour == bfd_target_ihex_flavour || our_flavour == bfd_target_tekhex_flavour) return NULL; /* No symbols. */ - for (i = 0; VEC_iterate (registered_sym_fns, symtab_fns, i, rsf); ++i) - if (our_flavour == rsf->sym_flavour) - return rsf->sym_fns; + for (const registered_sym_fns &rsf : symtab_fns) + if (our_flavour == rsf.sym_flavour) + return rsf.sym_fns; error (_("I'm sorry, Dave, I can't do that. Symbol format `%s' unknown."), bfd_get_target (abfd)); |