This is the mail archive of the gdb-cvs@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]

[binutils-gdb] Use ui_file_as_string in gdb/top.c


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7b01d34b2a62fb8cda96fe40c755f99e63b8ba4f

commit 7b01d34b2a62fb8cda96fe40c755f99e63b8ba4f
Author: Pedro Alves <palves@redhat.com>
Date:   Tue Nov 8 15:26:45 2016 +0000

    Use ui_file_as_string in gdb/top.c
    
    Yet another cleanup is eliminated.
    
    gdb/ChangeLog:
    2016-11-08  Pedro Alves  <palves@redhat.com>
    
    	* top.c (quit_confirm): Use ui_file_as_string and std::string.

Diff:
---
 gdb/ChangeLog | 4 ++++
 gdb/top.c     | 9 +++------
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 68f8cf0..08699ed 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
 2016-11-08  Pedro Alves  <palves@redhat.com>
 
+	* top.c (quit_confirm): Use ui_file_as_string and std::string.
+
+2016-11-08  Pedro Alves  <palves@redhat.com>
+
 	* gdbcmd.h (execute_command_to_string): Now returns std::string.
 	(lookup_struct_elt_type): Adjust to use std::string.
 	* top.c (execute_command_to_string): Use ui_file_as_string and
diff --git a/gdb/top.c b/gdb/top.c
index 504a4de..7d8b6e8 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1576,8 +1576,6 @@ quit_confirm (void)
 {
   struct ui_file *stb;
   struct cleanup *old_chain;
-  char *str;
-  int qr;
 
   /* Don't even ask if we're only debugging a core file inferior.  */
   if (!have_live_inferiors ())
@@ -1591,12 +1589,11 @@ quit_confirm (void)
   iterate_over_inferiors (print_inferior_quit_action, stb);
   fprintf_filtered (stb, _("\nQuit anyway? "));
 
-  str = ui_file_xstrdup (stb, NULL);
-  make_cleanup (xfree, str);
+  std::string str = ui_file_as_string (stb);
 
-  qr = query ("%s", str);
   do_cleanups (old_chain);
-  return qr;
+
+  return query ("%s", str.c_str ());
 }
 
 /* Prepare to exit GDB cleanly by undoing any changes made to the


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