Remove cleanup from complaints.c
authorTom Tromey <tom@tromey.com>
Thu, 28 Sep 2017 02:54:17 +0000 (20:54 -0600)
committerTom Tromey <tom@tromey.com>
Sat, 30 Sep 2017 02:46:44 +0000 (20:46 -0600)
This removes a cleanup from complaints.c by using std::string.

gdb/ChangeLog
2017-09-29  Tom Tromey  <tom@tromey.com>

* complaints.c (vcomplaint): Use std::string.

gdb/ChangeLog
gdb/complaints.c

index fda159245893c474c3ae910a3673117b96003496..d2678d4bb6963957a2844861d7368525ff5da291 100644 (file)
@@ -1,3 +1,7 @@
+2017-09-29  Tom Tromey  <tom@tromey.com>
+
+       * complaints.c (vcomplaint): Use std::string.
+
 2017-09-29  Tom Tromey  <tom@tromey.com>
 
        * tracepoint.c (trace_variable_command): Use std::string.
index aba305c72925c74520a3bee1c893abfc3583bc5b..58b6b7b51c3b477de20dd104817436ccd3bb2deb 100644 (file)
@@ -192,16 +192,14 @@ vcomplaint (struct complaints **c, const char *file,
        vwarning (fmt, args);
       else
        {
-         char *msg;
-         struct cleanup *cleanups;
-         msg = xstrvprintf (fmt, args);
-         cleanups = make_cleanup (xfree, msg);
+         std::string msg = string_vprintf (fmt, args);
          wrap_here ("");
          if (series != SUBSEQUENT_MESSAGE)
            begin_line ();
          /* XXX: i18n */
          fprintf_filtered (gdb_stderr, "%s%s%s",
-                           complaints->explanation[series].prefix, msg,
+                           complaints->explanation[series].prefix,
+                           msg.c_str (),
                            complaints->explanation[series].postfix);
          /* Force a line-break after any isolated message.  For the
              other cases, clear_complaints() takes care of any missing
@@ -214,7 +212,6 @@ vcomplaint (struct complaints **c, const char *file,
            fputs_filtered ("\n", gdb_stderr);
          else
            wrap_here ("");
-         do_cleanups (cleanups);
        }
     }