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 02/11] Remove cleanups from mi_cmd_break_insert_1


On 09/12/2017 07:57 PM, Tom Tromey wrote:

>  	* target.h (make_scoped_defer_target_commit_resume): Update.
>  	* target.c (make_scoped_defer_target_commit_resume): Rename from
>  	make_cleanup_defer_target_commit_resume.  Return a
> diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c
> index bae8711..4cd134c 100644
> --- a/gdb/mi/mi-cmd-break.c
> +++ b/gdb/mi/mi-cmd-break.c
> @@ -86,12 +86,11 @@ setup_breakpoint_reporting (void)
>  /* Convert arguments in ARGV to the string in "format",argv,argv...
>     and return it.  */
>  
> -static char *
> +static std::string
>  mi_argv_to_format (char **argv, int argc)
>  {
>    int i;
> -  struct obstack obstack;
> -  char *ret;
> +  auto_obstack obstack;
>  
>    obstack_init (&obstack);

Remove the obstack_init call too.

>  
> @@ -152,10 +151,7 @@ mi_argv_to_format (char **argv, int argc)
>      }
>    obstack_1grow (&obstack, '\0');
>  
> -  ret = xstrdup ((const char *) obstack_finish (&obstack));
> -  obstack_free (&obstack, NULL);
> -
> -  return ret;
> +  return (const char *) obstack_finish (&obstack);
>  }

OK.

IMO, it'd be even better to build the std::string directly
instead of building an obstack and then dupping the string.

Thanks,
Pedro Alves


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