D4118: index: make node tree a Python object
yuja (Yuya Nishihara)
phabricator at mercurial-scm.org
Mon Aug 20 18:51:49 EDT 2018
yuja added a comment.
> static int nt_init(nodetree *self, indexObject *index, unsigned capacity)
> {
>
> + /* Initialize before argument-checking to avoid nt_dealloc() crash. */
> + self->nodes = NULL;
This comment seems a bit confusing since another argument-checking is done
before `nt_init_py()`.
> self->index = index;
>
> + Py_INCREF(index);
>
> /* The input capacity is in terms of revisions, while the field is in
> * terms of nodetree nodes. */
> self->capacity = (capacity < 4 ? 4 : capacity / 2);
>
> @@ -1083,6 +1088,15 @@
>
> return 0;
> }
>
>
> +static int nt_init_py(nodetree *self, PyObject *args)
> +{
> + PyObject *index;
> + unsigned capacity;
> + if (!PyArg_ParseTuple(args, "O!I", &index, &capacity))
> + return -1;
> + return nt_init(self, (indexObject*)index, capacity);
> +}
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