This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA 16/20] Use gdbpy_enter in gdbpy_get_matching_xmethod_workers


>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

>> -      Py_DECREF (temp);
>> -      Py_DECREF (pspace_matchers);

Pedro> I'm a little confused here.  Don't we still need to account for
Pedro> these two Py_DECREFs?

The patch reads a little messily.  The new code is:

      gdbpy_reference pspace_matchers (pspy_get_xmethods (py_progspace, NULL));

      gdbpy_reference temp (PySequence_Concat (py_xmethod_matcher_list.get (),
					       pspace_matchers.get ()));
      if (temp == NULL)
	{
	  gdbpy_print_stack ();
	  return EXT_LANG_RC_ERROR;
	}

      py_xmethod_matcher_list = temp;

So the decrefs are accounted for by the destructors; and that assignment
at the end encodes an incref via the copy constructor.  Moving here
would have been a valid choice as well, like:

     py_xmethod_matcher_list = std::move (temp);

... though I deleted the move constructor since it wasn't used in the
earlier series and Jan pointed out that it had a bug.

Tom


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]