This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] Remove cleanups from dbxread.c


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]