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 3/8] Use std::string in utils.c


On 10/01/2017 05:06 AM, Tom Tromey wrote:

>    /* Don't allow infinite error/warning recursion.  */
>    {
> @@ -429,18 +428,17 @@ internal_vproblem (struct internal_problem *problem,
>      char *msg;
>  
>      msg = xstrvprintf (fmt, ap);
> -    reason = xstrprintf ("%s:%d: %s: %s\n"
> -			 "A problem internal to GDB has been detected,\n"
> -			 "further debugging may prove unreliable.",
> -			 file, line, problem->name, msg);
> +    reason = string_printf ("%s:%d: %s: %s\n"
> +			    "A problem internal to GDB has been detected,\n"
> +			    "further debugging may prove unreliable.",
> +			    file, line, problem->name, msg);
>      xfree (msg);
> -    make_cleanup (xfree, reason);

Could you please make msg use string_vprintf too while at it, thus
getting rid of that bare xfree?

(Similarly to the defaulted_query change below, though there we
were using a cleanup.)

Looks good to me with that change.

Thanks,
Pedro Alves

> @@ -978,13 +975,12 @@ defaulted_query (const char *ctlstr, const char defchar, va_list args)
>      }
>  
>    /* Format the question outside of the loop, to avoid reusing args.  */
> -  question = xstrvprintf (ctlstr, args);
> -  old_chain = make_cleanup (xfree, question);
> -  prompt = xstrprintf (_("%s%s(%s or %s) %s"),
> -		      annotation_level > 1 ? "\n\032\032pre-query\n" : "",
> -		      question, y_string, n_string,
> -		      annotation_level > 1 ? "\n\032\032query\n" : "");
> -  make_cleanup (xfree, prompt);
> +  std::string question = string_vprintf (ctlstr, args);
> +  std::string prompt
> +    = string_printf (_("%s%s(%s or %s) %s"),
> +		     annotation_level > 1 ? "\n\032\032pre-query\n" : "",
> +		     question.c_str (), y_string, n_string,
> +		     annotation_level > 1 ? "\n\032\032query\n" : "");
>  


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