[PATCH 08 of 11] parsers: use Python memory allocator in compute_phases_map_sets()
Gregory Szorc
gregory.szorc at gmail.com
Thu Mar 9 16:59:16 EST 2017
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1489090353 28800
# Thu Mar 09 12:12:33 2017 -0800
# Node ID 66d9008cce9f3b543edf564956d804143747d3c6
# Parent a53adfed7bea034f87d3d603e04dd04e7b16137f
parsers: use Python memory allocator in compute_phases_map_sets()
diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -1348,11 +1348,14 @@ static PyObject *compute_phases_map_sets
if (roots == NULL || !PyList_Check(roots))
goto done;
- phases = calloc(len, 1); /* phase per rev: {0: public, 1: draft, 2: secret} */
+ /* phase per rev: {0: public, 1: draft, 2: secret} */
+ phases = PyMem_Malloc(len);
if (phases == NULL) {
PyErr_NoMemory();
goto done;
}
+ memset(phases, 0, len);
+
/* Put the phase information of all the roots in phases */
numphase = PyList_GET_SIZE(roots)+1;
minrevallphases = len + 1;
@@ -1415,7 +1418,7 @@ release:
Py_XDECREF(phaseslist);
Py_XDECREF(phasessetlist);
done:
- free(phases);
+ PyMem_Free(phases);
return ret;
}
More information about the Mercurial-devel
mailing list