D4118: index: make node tree a Python object

yuja (Yuya Nishihara) phabricator at mercurial-scm.org
Tue Aug 7 10:03:39 EDT 2018


yuja added a comment.


  Can you bump the cext version as this patch introduces new API?
  
  > +static int nt_init_py(nodetree *self, PyObject *args)
  >  +{
  >  +	PyObject *index;
  >  +	unsigned capacity;
  >  +	if (!PyArg_ParseTuple(args, "OI", &index, &capacity))
  >  +		return -1;
  
  It leaves self->nodes uninitialized on error, and nt_dealloc() would fail if
  self->nodes wasn't luckily 0. Strictly speaking, it's too late to initialize
  pointers in tp_init because __init__() may be called more than once, but our
  C types don't handle such cases.
  
  > +	return nt_init(self, (indexObject*)index, capacity);
  
  We'll probably need INCREF/DECREF business for the index object.
  
  I didn't review the other refcounting thingy carefully. Since it's painful
  to do refcounting right, an internal nodetree could be embedded in the
  indexObject, and a thin PyObject wrapper could be added. Just an idea.
  
    struct nodetree {
    };
    
    struct nodetreeObject {
        PyObject_HEAD
        nodetree nt;
    };
    
    struct indexObject {
        ...
        nodetree nt;
        ...
    };

REPOSITORY
  rHG Mercurial

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

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


More information about the Mercurial-devel mailing list