D4118: index: make node tree a Python object

Yuya Nishihara yuya at tcha.org
Wed Aug 22 08:12:00 EDT 2018


>  static int nt_init(nodetree *self, indexObject *index, unsigned capacity)
>  {
> +	/* Initialize before argument-checking to avoid nt_dealloc() crash. */
> +	self->nodes = NULL;
> +
>  	self->index = index;
> +	Py_INCREF(index);

While thinking about a pure nodetree, I noticed this makes a similar situation
to reference cycle between two C objects, index and index->nt. The index can't
be freed until index->nt gets deleted.

Perhaps the easiest way around is to convert an internal nodetree back to
a plain C struct.


More information about the Mercurial-devel mailing list