diff options
author | Tom Tromey <tom@tromey.com> | 2017-09-27 20:38:07 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-09-29 20:46:43 -0600 |
commit | 200aa7b154b25423eb72ceecade0fcd76edc4686 (patch) | |
tree | 643c7eb8f0b71f2db9b71529c2946336384ff399 /gdb | |
parent | 606aae8a73177dde47ff01a6eb7ec883309bdfa6 (diff) | |
download | gdb-200aa7b154b25423eb72ceecade0fcd76edc4686.zip gdb-200aa7b154b25423eb72ceecade0fcd76edc4686.tar.gz gdb-200aa7b154b25423eb72ceecade0fcd76edc4686.tar.bz2 |
Remove cleanups from utils.c
This removes a couple of cleanups from utils.c through the use of
std::string.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* utils.c (vfprintf_maybe_filtered): Use std::string.
(vfprintf_unfiltered): Likewise.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/utils.c | 23 |
2 files changed, 12 insertions, 16 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 48f1f89..0e76e7f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2017-09-29 Tom Tromey <tom@tromey.com> + * utils.c (vfprintf_maybe_filtered): Use std::string. + (vfprintf_unfiltered): Likewise. + +2017-09-29 Tom Tromey <tom@tromey.com> + * event-top.c (top_level_prompt): Return std::string. (display_gdb_prompt): Update. diff --git a/gdb/utils.c b/gdb/utils.c index 24294be..b2e0813 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -2036,13 +2036,8 @@ static void vfprintf_maybe_filtered (struct ui_file *stream, const char *format, va_list args, int filter) { - char *linebuffer; - struct cleanup *old_cleanups; - - linebuffer = xstrvprintf (format, args); - old_cleanups = make_cleanup (xfree, linebuffer); - fputs_maybe_filtered (linebuffer, stream, filter); - do_cleanups (old_cleanups); + std::string linebuffer = string_vprintf (format, args); + fputs_maybe_filtered (linebuffer.c_str (), stream, filter); } @@ -2055,11 +2050,7 @@ vfprintf_filtered (struct ui_file *stream, const char *format, va_list args) void vfprintf_unfiltered (struct ui_file *stream, const char *format, va_list args) { - char *linebuffer; - struct cleanup *old_cleanups; - - linebuffer = xstrvprintf (format, args); - old_cleanups = make_cleanup (xfree, linebuffer); + std::string linebuffer = string_vprintf (format, args); if (debug_timestamp && stream == gdb_stdlog) { using namespace std::chrono; @@ -2069,18 +2060,18 @@ vfprintf_unfiltered (struct ui_file *stream, const char *format, va_list args) seconds s = duration_cast<seconds> (now.time_since_epoch ()); microseconds us = duration_cast<microseconds> (now.time_since_epoch () - s); - len = strlen (linebuffer); + len = linebuffer.size (); need_nl = (len > 0 && linebuffer[len - 1] != '\n'); std::string timestamp = string_printf ("%ld.%06ld %s%s", (long) s.count (), (long) us.count (), - linebuffer, need_nl ? "\n": ""); + linebuffer.c_str (), + need_nl ? "\n": ""); fputs_unfiltered (timestamp.c_str (), stream); } else - fputs_unfiltered (linebuffer, stream); - do_cleanups (old_cleanups); + fputs_unfiltered (linebuffer.c_str (), stream); } void |