[PATCH 2 of 6] parsers.c: parse_index: use named labels and DECREF instead of a generic quit
Nicolas Dumazet
nicdumz at gmail.com
Thu Aug 27 08:09:11 CDT 2009
# HG changeset patch
# User Nicolas Dumazet <nicdumz.commits at gmail.com>
# Date 1251369670 -7200
# Node ID a235d3e45140f5532b3e7886f7beada51675bde4
# Parent fdd0c8cdca78d000e76e895519abde0eeb0bbad1
parsers.c: parse_index: use named labels and DECREF instead of a generic quit
This way, we call DECREF only we we _know_ that its refcount has to be
decremented. We also understand that rval never needs to de DECREF'ed:
it's either NULL, either the correct, returned value.
diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -384,11 +384,11 @@
* plus one for the nullid */
index = inlined ? PyList_New(0) : PyList_New(size / 64 + 1);
if (!index)
- goto quit;
+ return NULL;
nodemap = PyDict_New();
if (!nodemap)
- goto quit;
+ goto err_nonodemap;
/* set up the cache return value */
if (inlined) {
@@ -396,7 +396,7 @@
data_obj = PyTuple_GET_ITEM(args, 0);
cache = Py_BuildValue("iO", 0, data_obj);
if (!cache)
- goto quit;
+ goto err_nocache;
} else {
cache = Py_None;
Py_INCREF(Py_None);
@@ -412,10 +412,11 @@
return rval;
quit:
- Py_XDECREF(index);
- Py_XDECREF(nodemap);
- Py_XDECREF(cache);
- Py_XDECREF(rval);
+ Py_DECREF(cache);
+err_nocache:
+ Py_DECREF(nodemap);
+err_nonodemap:
+ Py_DECREF(index);
return NULL;
}
More information about the Mercurial-devel
mailing list