if (!result)
{
PyObject *ptype, *pvalue, *ptraceback;
- char *msg;
PyErr_Fetch (&ptype, &pvalue, &ptraceback);
When fetching the error message we need to make our own copy,
we no longer own ptype, pvalue after the call to PyErr_Restore. */
- msg = gdbpy_exception_to_string (ptype, pvalue);
- make_cleanup (xfree, msg);
+ gdb::unique_xmalloc_ptr<char>
+ msg (gdbpy_exception_to_string (ptype, pvalue));
if (msg == NULL)
{
gdbpy_print_stack ();
if (msg != NULL && *msg != '\0')
error (_("Error occurred in Python convenience function: %s"),
- msg);
+ msg.get ());
else
error (_("Error occurred in Python convenience function."));
}
Py_XDECREF (ptype);
Py_XDECREF (pvalue);
Py_XDECREF (ptraceback);
- error ("%s", msg);
+ error ("%s", msg.get ());
}
}
fnpy_init (PyObject *self, PyObject *args, PyObject *kwds)
{
const char *name;
- char *docstring = NULL;
+ gdb::unique_xmalloc_ptr<char> docstring;
if (! PyArg_ParseTuple (args, "s", &name))
return -1;
}
}
if (! docstring)
- docstring = xstrdup (_("This function is not documented."));
+ docstring.reset (xstrdup (_("This function is not documented.")));
- add_internal_function (name, docstring, fnpy_call, self);
+ add_internal_function (name, docstring.release (), fnpy_call, self);
return 0;
}