Change pspace_to_pspace_object to return a new reference
This changes pspace_to_pspace_object to return a new reference and fixes up all the callers. gdb/ChangeLog 2018-09-16 Tom Tromey <tom@tromey.com> * python/py-inferior.c (infpy_get_progspace): Update. * python/python-internal.h (pspace_to_pspace_object): Change return type. * python/py-newobjfileevent.c (create_clear_objfiles_event_object): Update. * python/py-xmethods.c (gdbpy_get_matching_xmethod_workers): Update. * python/python.c (gdbpy_get_current_progspace): Update. (gdbpy_progspaces): Update. * python/py-progspace.c (pspace_to_pspace_object): Return a new reference. * python/py-objfile.c (objfpy_get_progspace): Update. * python/py-prettyprint.c (find_pretty_printer_from_progspace): Update.
This commit is contained in:
parent
8743a9cdd2
commit
3c7aa30778
9 changed files with 47 additions and 39 deletions
|
@ -492,30 +492,31 @@ py_free_pspace (struct program_space *pspace, void *datum)
|
|||
object->pspace = NULL;
|
||||
}
|
||||
|
||||
/* Return a borrowed reference to the Python object of type Pspace
|
||||
/* Return a new reference to the Python object of type Pspace
|
||||
representing PSPACE. If the object has already been created,
|
||||
return it. Otherwise, create it. Return NULL and set the Python
|
||||
error on failure. */
|
||||
|
||||
PyObject *
|
||||
gdbpy_ref<>
|
||||
pspace_to_pspace_object (struct program_space *pspace)
|
||||
{
|
||||
gdbpy_ref<pspace_object> object
|
||||
((pspace_object *) program_space_data (pspace, pspy_pspace_data_key));
|
||||
if (object == NULL)
|
||||
PyObject *result
|
||||
((PyObject *) program_space_data (pspace, pspy_pspace_data_key));
|
||||
if (result == NULL)
|
||||
{
|
||||
object.reset (PyObject_New (pspace_object, &pspace_object_type));
|
||||
if (object != NULL)
|
||||
{
|
||||
if (!pspy_initialize (object.get ()))
|
||||
return NULL;
|
||||
gdbpy_ref<pspace_object> object
|
||||
((pspace_object *) PyObject_New (pspace_object, &pspace_object_type));
|
||||
if (object == NULL)
|
||||
return NULL;
|
||||
if (!pspy_initialize (object.get ()))
|
||||
return NULL;
|
||||
|
||||
object->pspace = pspace;
|
||||
set_program_space_data (pspace, pspy_pspace_data_key, object.get ());
|
||||
}
|
||||
object->pspace = pspace;
|
||||
set_program_space_data (pspace, pspy_pspace_data_key, object.get ());
|
||||
result = (PyObject *) object.release ();
|
||||
}
|
||||
|
||||
return (PyObject *) object.release ();
|
||||
return gdbpy_ref<>::new_reference (result);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue