[RFA,1/4] Use std::string in ppscm_make_pp_type_error_exception

Message ID 20180527152009.4228-2-tom@tromey.com
State New, archived
Headers

Commit Message

Tom Tromey May 27, 2018, 3:20 p.m. UTC
  This changes ppscm_make_pp_type_error_exception to use std::string,
removing a cleanup.

ChangeLog
2018-05-26  Tom Tromey  <tom@tromey.com>

	* guile/scm-pretty-print.c (ppscm_make_pp_type_error_exception):
	Use string_printf.
---
 gdb/ChangeLog                |  5 +++++
 gdb/guile/scm-pretty-print.c | 14 ++++----------
 2 files changed, 9 insertions(+), 10 deletions(-)
  

Comments

Pedro Alves July 17, 2018, 1:08 p.m. UTC | #1
On 05/27/2018 04:20 PM, Tom Tromey wrote:
> This changes ppscm_make_pp_type_error_exception to use std::string,
> removing a cleanup.
> 
> ChangeLog
> 2018-05-26  Tom Tromey  <tom@tromey.com>
> 
> 	* guile/scm-pretty-print.c (ppscm_make_pp_type_error_exception):
> 	Use string_printf.

OK.

Thanks,
Pedro Alves
  

Patch

diff --git a/gdb/guile/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c
index da1b7d2be1..5e8a2a998d 100644
--- a/gdb/guile/scm-pretty-print.c
+++ b/gdb/guile/scm-pretty-print.c
@@ -327,16 +327,10 @@  gdbscm_pretty_printer_worker_p (SCM scm)
 static SCM
 ppscm_make_pp_type_error_exception (const char *message, SCM object)
 {
-  char *msg = xstrprintf ("%s: ~S", message);
-  struct cleanup *cleanup = make_cleanup (xfree, msg);
-  SCM exception
-    = gdbscm_make_error (pp_type_error_symbol,
-			 NULL /* func */, msg,
-			 scm_list_1 (object), scm_list_1 (object));
-
-  do_cleanups (cleanup);
-
-  return exception;
+  std::string msg = string_printf ("%s: ~S", message);
+  return gdbscm_make_error (pp_type_error_symbol,
+			    NULL /* func */, msg.c_str (),
+			    scm_list_1 (object), scm_list_1 (object));
 }
 
 /* Print MESSAGE as an exception (meaning it is controlled by