D4118: index: make node tree a Python object

yuja (Yuya Nishihara) phabricator at mercurial-scm.org
Thu Aug 9 08:42:59 EDT 2018


yuja added a comment.


  >   I think the default tp_new clears the memory of the object, so it won't be uninitialized (maybe that's what you mean by "luckily", but I first thought your meant it would require luck for it to be set to 0).
  
  Interesting. tp_alloc is documented to initialize memory to zeros.
  
  https://docs.python.org/2/c-api/typeobj.html#c.PyTypeObject.tp_alloc
  
  So https://phab.mercurial-scm.org/rHGe57c532c3835f6b244f21815cafcce0df1d272ce was a moot?
  
  > The only reason I think that might be the case is that we haven't seen any failures because of uninitialized memory in `index->nt` before (which used to be `index->nodes`).
  
  `self->nt` was initialized very first at `index_init()`.
  
  >   > 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.
  >   
  >   Do you mean the refcounting of the nodetree? Assuming that the previous calls to `free()` (which I changed to `PyMem_Free()`) were correct, shouldn't it still be correct after replacing those by `nt_dealloc()`?
  
  Refcounting of `self->nt`. I just meant I didn't review the code carefully.

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