Reduce manual reference counting in py-inferior.c
This patch changes py-inferior.c to use gdbpy_ref<> when possible, reducing the amount of manual reference counting. Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-07-10 Tom Tromey <tromey@adacore.com> * python/python-internal.h (create_thread_object): Return gdbpy_ref. * python/py-infthread.c (create_thread_object): Return gdbpy_ref. * python/py-inferior.c (struct threadlist_entry): Add constructor. <thread_obj>: Now a gdbpy_ref. (thread_to_thread_object): Update. (add_thread_object): Use new. (delete_thread_object): Use delete. (infpy_threads): Update. (py_free_inferior): Update. Construct "inf_obj" after acquiring GIL.
This commit is contained in:
parent
32372d80ca
commit
05b08ac160
4 changed files with 39 additions and 22 deletions
|
@ -36,17 +36,17 @@ extern PyTypeObject thread_object_type
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
thread_object *
|
||||
gdbpy_ref<thread_object>
|
||||
create_thread_object (struct thread_info *tp)
|
||||
{
|
||||
thread_object *thread_obj;
|
||||
gdbpy_ref<thread_object> thread_obj;
|
||||
|
||||
gdbpy_ref<inferior_object> inf_obj = inferior_to_inferior_object (tp->inf);
|
||||
if (inf_obj == NULL)
|
||||
return NULL;
|
||||
|
||||
thread_obj = PyObject_New (thread_object, &thread_object_type);
|
||||
if (!thread_obj)
|
||||
thread_obj.reset (PyObject_New (thread_object, &thread_object_type));
|
||||
if (thread_obj == NULL)
|
||||
return NULL;
|
||||
|
||||
thread_obj->thread = tp;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue