From: Simon Marchi Date: Wed, 11 Oct 2017 13:34:08 +0000 (-0400) Subject: Use std::vector for symtab_fns X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=905014d7205d4f171c5cabf695fe1ec3da9b33d3;p=binutils-gdb.git 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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1205355dce9..66ef8d6a03b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2017-10-11 Simon Marchi + + * 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. + 2017-10-11 Anton Kolesov * arc-tdep.c (arc_gdbarch_init): Pass proper cpu value to disassembler. diff --git a/gdb/symfile.c b/gdb/symfile.c index a74165456e8..b4abe84541b 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 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));