summaryrefslogtreecommitdiff
path: root/gdb/python/py-breakpoint.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-04-30 22:10:41 -0600
committerTom Tromey <tom@tromey.com>2017-08-03 07:59:07 -0600
commit7f968c899f21643322dcfaf807ec7d7bee7c9974 (patch)
treecc45bbdc0afdeb352f530fd22795c9a36774d8e0 /gdb/python/py-breakpoint.c
parent3c9ebddd93ffb8b44b8cc69f3be9db08c861368e (diff)
downloadbinutils-gdb-7f968c899f21643322dcfaf807ec7d7bee7c9974.tar.gz
Avoid some manual memory management in Python
This changes a few places in the Python code to avoid manual memory management, in favor of letting std::string do the work. ChangeLog 2017-08-03 Tom Tromey <tom@tromey.com> * python/python.c (compute_python_string): Return std::string. (gdbpy_eval_from_control_command): Update. (do_start_initialization): Use std::string. * python/py-varobj.c (py_varobj_iter_next): Use string_printf, not xstrprintf. * python/py-breakpoint.c (local_setattro): Use string_printf, not xstrprintf.
Diffstat (limited to 'gdb/python/py-breakpoint.c')
-rw-r--r--gdb/python/py-breakpoint.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index 64de8038b6f..6156eb6179b 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -1026,15 +1026,12 @@ local_setattro (PyObject *self, PyObject *name, PyObject *v)
extlang = get_breakpoint_cond_ext_lang (obj->bp, EXT_LANG_PYTHON);
if (extlang != NULL)
{
- char *error_text;
-
- error_text
- = xstrprintf (_("Only one stop condition allowed. There is"
- " currently a %s stop condition defined for"
- " this breakpoint."),
- ext_lang_capitalized_name (extlang));
- PyErr_SetString (PyExc_RuntimeError, error_text);
- xfree (error_text);
+ std::string error_text
+ = string_printf (_("Only one stop condition allowed. There is"
+ " currently a %s stop condition defined for"
+ " this breakpoint."),
+ ext_lang_capitalized_name (extlang));
+ PyErr_SetString (PyExc_RuntimeError, error_text.c_str ());
return -1;
}
}