Mercurial > hg-stable
changeset 45179:ba5e4b11d085
phases: rename variable used for owned dict of phasesets
The phaseroots variable is used for two different objects: borrowed set
and owned dict of sets. It's hard to track which object should have to be
decrefed on error return.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 18 Jul 2020 18:35:17 +0900 |
parents | b00fa1782efe |
children | a6fde9d789d9 |
files | mercurial/cext/revlog.c |
diffstat | 1 files changed, 8 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cext/revlog.c Sat Jul 18 18:27:39 2020 +0900 +++ b/mercurial/cext/revlog.c Sat Jul 18 18:35:17 2020 +0900 @@ -793,6 +793,7 @@ PyObject *roots = Py_None; PyObject *pyphase = NULL; PyObject *pyrev = NULL; + PyObject *phasesetsdict = NULL; PyObject *phaseroots = NULL; PyObject *phasesets[4] = {NULL, NULL, NULL, NULL}; Py_ssize_t len = index_length(self); @@ -880,14 +881,16 @@ } Py_DECREF(pyrev); } - phaseroots = _dict_new_presized(numphases); - if (phaseroots == NULL) + + phasesetsdict = _dict_new_presized(numphases); + if (phasesetsdict == NULL) goto release; for (i = 0; i < numphases; ++i) { pyphase = PyInt_FromLong(trackedphases[i]); if (pyphase == NULL) goto release; - if (PyDict_SetItem(phaseroots, pyphase, phasesets[i]) == -1) { + if (PyDict_SetItem(phasesetsdict, pyphase, phasesets[i]) == + -1) { Py_DECREF(pyphase); goto release; } @@ -895,12 +898,12 @@ phasesets[i] = NULL; } - return Py_BuildValue("nN", len, phaseroots); + return Py_BuildValue("nN", len, phasesetsdict); release: for (i = 0; i < numphases; ++i) Py_XDECREF(phasesets[i]); - Py_XDECREF(phaseroots); + Py_XDECREF(phasesetsdict); free(phases); return NULL;