Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Sergio Durigan Junior <sergiodj@redhat.com>
Cc: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [RFA v2 1/4] C++-ify break-catch-sig
Date: Fri, 21 Jul 2017 19:53:00 -0000	[thread overview]
Message-ID: <562efb619fe2c15a3c5c039770e3158f@polymtl.ca> (raw)
In-Reply-To: <87d18vkmdb.fsf@redhat.com>

On 2017-07-20 20:13, Sergio Durigan Junior wrote:
>> 
>>    while (*arg != '\0')
>>      {
>>        int num;
>> -      gdb_signal_type signal_number;
>> -      char *one_arg, *endptr;
>> -      struct cleanup *inner_cleanup;
>> +      gdb_signal signal_number;
>> +      char *endptr;
>> 
>> -      one_arg = extract_arg (&arg);
>> +      gdb::unique_xmalloc_ptr<char> one_arg (extract_arg (&arg));
>>        if (one_arg == NULL)
>>  	break;
>> -      inner_cleanup = make_cleanup (xfree, one_arg);
>> 
>>        /* Check for the special flag "all".  */
>> -      if (strcmp (one_arg, "all") == 0)
>> +      if (strcmp (one_arg.get (), "all") == 0)
>>  	{
>>  	  arg = skip_spaces (arg);
>>  	  if (*arg != '\0' || !first)
>>  	    error (_("'all' cannot be caught with other signals"));
>> -	  *catch_all = 1;
>> -	  gdb_assert (result == NULL);
>> -	  do_cleanups (inner_cleanup);
>> -	  discard_cleanups (cleanup);
>> -	  return NULL;
>> +	  *catch_all = true;
>> +	  gdb_assert (result.empty ());
>> +	  return result;
>>  	}
>> 
>>        first = 0;
>> 
>>        /* Check if the user provided a signal name or a number.  */
>> -      num = (int) strtol (one_arg, &endptr, 0);
>> +      num = (int) strtol (one_arg.get (), &endptr, 0);
>>        if (*endptr == '\0')
>>  	signal_number = gdb_signal_from_command (num);
>>        else
>>  	{
>> -	  signal_number = gdb_signal_from_name (one_arg);
>> +	  signal_number = gdb_signal_from_name (one_arg.get ());
>>  	  if (signal_number == GDB_SIGNAL_UNKNOWN)
>> -	    error (_("Unknown signal name '%s'."), one_arg);
>> +	    error (_("Unknown signal name '%s'."), one_arg.get ());
>>  	}
>> 
>> -      VEC_safe_push (gdb_signal_type, result, signal_number);
>> -      do_cleanups (inner_cleanup);
>> +      result.push_back (signal_number);
>>      }
>> 
>> -  discard_cleanups (cleanup);
>> +  result.shrink_to_fit ();
> 
> Do you really need this call here?  You're using safe_push above, so I
> don't think the vector will end up with a bigger capacity than its 
> size.

safe_push is the old implementations, std::vector grows the capacity 
exponentially, so you're likely to be left with unused capacity.

Simon


  reply	other threads:[~2017-07-21 19:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-19 20:53 [RFA v2 0/4] C++-ify some breakpoint subclasses a bit more Tom Tromey
2017-07-19 20:51 ` [RFA v2 1/4] C++-ify break-catch-sig Tom Tromey
2017-07-20 18:13   ` Sergio Durigan Junior
2017-07-21 19:53     ` Simon Marchi [this message]
2017-07-22  3:53     ` Tom Tromey
2017-07-21 19:43   ` Simon Marchi
2017-07-19 20:53 ` [RFA v2 2/4] C++-ify break-catch-throw Tom Tromey
2017-07-20 17:57   ` Sergio Durigan Junior
2017-07-21 20:20   ` Simon Marchi
2017-07-19 20:53 ` [RFA v2 3/4] Use std::vector in syscall_catchpoint Tom Tromey
2017-07-20 17:55   ` Sergio Durigan Junior
2017-07-21 20:37   ` Simon Marchi
2017-07-19 20:54 ` [RFA v2 4/4] Use std::vector in struct catch_syscall_inferior_data Tom Tromey
2017-07-20 16:58   ` Sergio Durigan Junior
2017-07-22  3:43     ` Tom Tromey
2017-07-21 20:49   ` Simon Marchi

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=562efb619fe2c15a3c5c039770e3158f@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=sergiodj@redhat.com \
    --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