Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [RFA] Remove cleanups from dbxread.c
Date: Fri, 25 May 2018 16:55:00 -0000	[thread overview]
Message-ID: <f7a6684e-0160-7193-606e-821eb5a99d93@redhat.com> (raw)
In-Reply-To: <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


  reply	other threads:[~2018-05-25 16:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-25 16:07 Tom Tromey
2018-05-25 16:55 ` Pedro Alves [this message]
2018-05-25 17:12   ` Tom Tromey
2018-05-25 19:20     ` Pedro Alves
2018-05-25 19:50       ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f7a6684e-0160-7193-606e-821eb5a99d93@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox