D4372: index: embed nodetree in index object to avoid reference cycle

yuja (Yuya Nishihara) phabricator at mercurial-scm.org
Sat Aug 25 05:35:03 EDT 2018


yuja added a comment.


  > -static int nt_init_py(nodetree *self, PyObject *args)
  >  +static int ntobj_init(nodetreeObject *self, PyObject *args)
  > 
  >   {
  >   	PyObject *index;
  >   	unsigned capacity;
  > 
  > +	int ret;
  > 
  >   	if (!PyArg_ParseTuple(args, "O!I", &indexType, &index, &capacity))
  >   		return -1;
  > 
  > - return nt_init(self, (indexObject*)index, capacity); +	ret = nt_init(&self->nt, (indexObject*)index, capacity); +	if (ret == 0) { +	  Py_INCREF(index); +	}
  
  Perhaps index should be increfed no matter if nt_init() succeeds or not,
  since the self is ntobj_dealloc()-ed anyway.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D4372

To: martinvonz, #hg-reviewers
Cc: yuja, mercurial-devel


More information about the Mercurial-devel mailing list