Replace xstrvprintf usages with string_vprintf
Most usages of xstrvprintf in GDB can be replaced with string_vprintf, removing some manual memory management. gdb/ChangeLog: * guile/scm-string.c (gdbscm_scm_from_printf): Use string_vprintf. * guile/scm-utils.c (gdbscm_printf): Likewise. * serial.c (serial_printf): Likewise. * xml-support.c (gdb_xml_parser::vdebug): Likewise.
This commit is contained in:
parent
6d52907e22
commit
467dc1e2ea
@ -1,3 +1,11 @@
|
||||
2018-08-22 Simon Marchi <simon.marchi@polymtl.ca>
|
||||
|
||||
* guile/scm-string.c (gdbscm_scm_from_printf): Use
|
||||
string_vprintf.
|
||||
* guile/scm-utils.c (gdbscm_printf): Likewise.
|
||||
* serial.c (serial_printf): Likewise.
|
||||
* xml-support.c (gdb_xml_parser::vdebug): Likewise.
|
||||
|
||||
2018-08-22 Jan Vrany <jan.vrany@fit.cvut.cz>
|
||||
|
||||
* stack.c (print_frame): Print frame architecture when printing on
|
||||
|
@ -62,14 +62,12 @@ SCM
|
||||
gdbscm_scm_from_printf (const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
char *string;
|
||||
SCM result;
|
||||
|
||||
va_start (args, format);
|
||||
string = xstrvprintf (format, args);
|
||||
std::string string = string_vprintf (format, args);
|
||||
va_end (args);
|
||||
result = scm_from_latin1_string (string);
|
||||
xfree (string);
|
||||
result = scm_from_latin1_string (string.c_str ());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -79,13 +79,11 @@ void
|
||||
gdbscm_printf (SCM port, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
char *string;
|
||||
|
||||
va_start (args, format);
|
||||
string = xstrvprintf (format, args);
|
||||
std::string string = string_vprintf (format, args);
|
||||
va_end (args);
|
||||
scm_puts (string, port);
|
||||
xfree (string);
|
||||
scm_puts (string.c_str (), port);
|
||||
}
|
||||
|
||||
/* Utility for calling from gdb to "display" an SCM object. */
|
||||
|
@ -434,16 +434,14 @@ serial_write (struct serial *scb, const void *buf, size_t count)
|
||||
}
|
||||
|
||||
void
|
||||
serial_printf (struct serial *desc, const char *format,...)
|
||||
serial_printf (struct serial *desc, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
char *buf;
|
||||
va_start (args, format);
|
||||
|
||||
buf = xstrvprintf (format, args);
|
||||
serial_write (desc, buf, strlen (buf));
|
||||
std::string buf = string_vprintf (format, args);
|
||||
serial_write (desc, buf.c_str (), buf.length ());
|
||||
|
||||
xfree (buf);
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
|
@ -179,16 +179,14 @@ void
|
||||
gdb_xml_parser::vdebug (const char *format, va_list ap)
|
||||
{
|
||||
int line = XML_GetCurrentLineNumber (m_expat_parser);
|
||||
char *message;
|
||||
|
||||
message = xstrvprintf (format, ap);
|
||||
std::string message = string_vprintf (format, ap);
|
||||
if (line)
|
||||
fprintf_unfiltered (gdb_stderr, "%s (line %d): %s\n",
|
||||
m_name, line, message);
|
||||
m_name, line, message.c_str ());
|
||||
else
|
||||
fprintf_unfiltered (gdb_stderr, "%s: %s\n",
|
||||
m_name, message);
|
||||
xfree (message);
|
||||
m_name, message.c_str ());
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user