This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] Remove cleanups from dbxread.c
- From: Pedro Alves <palves at redhat dot com>
- To: Tom Tromey <tom at tromey dot com>, gdb-patches at sourceware dot org
- Date: Fri, 25 May 2018 17:30:01 +0100
- Subject: Re: [RFA] Remove cleanups from dbxread.c
- References: <20180525150441.25246-1-tom@tromey.com>
On 05/25/2018 04:04 PM, Tom Tromey wrote:
> This removes the remaining cleanups from dbxread.c, via std::vector,
> scoped_restore, and unique_xmalloc_ptr.
>
> Tested by the buildbot, but I'm not sure these code paths are actually
> exercised there.
Maybe not. Could just just smoke test some -gstabs binary, just
in case?
Looks good to me. Just a couple comments below.
> /* The actual list and controling variables. */
> -static struct header_file_location *bincl_list, *next_bincl;
> -static int bincls_allocated;
> +static std::vector<struct header_file_location> *bincl_list;
I guess the "controlling variables" was "bincls_allocated", which
is now gone. Maybe adjust the comment?
> /* Add a bincl to the list. */
>
> static void
> add_bincl_to_list (struct partial_symtab *pst, const char *name, int instance)
> {
> - if (next_bincl >= bincl_list + bincls_allocated)
> - {
> - int offset = next_bincl - bincl_list;
> + bincl_list->emplace_back ();
> + struct header_file_location *next_bincl = &bincl_list->back ();
>
> - bincls_allocated *= 2;
> - bincl_list = (struct header_file_location *)
> - xrealloc ((char *) bincl_list,
> - bincls_allocated * sizeof (struct header_file_location));
> - next_bincl = bincl_list + offset;
> - }
> next_bincl->pst = pst;
> next_bincl->instance = instance;
> - next_bincl++->name = name;
> + next_bincl->name = name;
> }
I guess we could add a ctor to header_file_location, so
we'd could write:
bincl_list->emplace_back (pst, name, instance);
Could even remove add_bincl_to_list then, I guess.
Anyway, I totally understand if you want to stay strictly
focused on the cleanups aspect, and this is not a request.
That is OK.
Thanks,
Pedro Alves