/* Convenience functions implemented in Python.
- Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
This file is part of GDB.
{
int i;
PyObject *result = PyTuple_New (argc);
+
for (i = 0; i < argc; ++i)
{
PyObject *elt = value_to_value_object (argv[i]);
fnpy_call (struct gdbarch *gdbarch, const struct language_defn *language,
void *cookie, int argc, struct value **argv)
{
- int i;
struct value *value = NULL;
PyObject *result, *callable, *args;
struct cleanup *cleanup;
fnpy_init (PyObject *self, PyObject *args, PyObject *kwds)
{
char *name, *docstring = NULL;
+
if (! PyArg_ParseTuple (args, "s", &name))
return -1;
Py_INCREF (self);
{
PyObject *ds_obj = PyObject_GetAttrString (self, "__doc__");
if (ds_obj && gdbpy_is_string (ds_obj))
- /* Nothing ever frees this. */
- docstring = python_string_to_host_string (ds_obj);
+ {
+ docstring = python_string_to_host_string (ds_obj);
+ if (docstring == NULL)
+ {
+ Py_DECREF (self);
+ return -1;
+ }
+ }
}
if (! docstring)
- docstring = _("This function is not documented.");
+ docstring = xstrdup (_("This function is not documented."));
add_internal_function (name, docstring, fnpy_call, self);
return 0;