[PATCH] parsers: use Py_CLEAR where appropriate

Bryan O'Sullivan bos at serpentine.com
Sun May 13 04:56:55 CDT 2012


# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1336903010 -7200
# Node ID f4c977be479b409ed8d3e305ca3b0c8233a0ecfd
# Parent  9593f56e7a50e14a0b08fe9fed0d0658728e410d
parsers: use Py_CLEAR where appropriate

diff -r 9593f56e7a50 -r f4c977be479b mercurial/parsers.c
--- a/mercurial/parsers.c	Sun May 13 11:53:52 2012 +0200
+++ b/mercurial/parsers.c	Sun May 13 11:56:50 2012 +0200
@@ -474,12 +474,8 @@
 	if (self->cache) {
 		Py_ssize_t i;
 
-		for (i = 0; i < self->raw_length; i++) {
-			if (self->cache[i]) {
-				Py_DECREF(self->cache[i]);
-				self->cache[i] = NULL;
-			}
-		}
+		for (i = 0; i < self->raw_length; i++)
+			Py_CLEAR(self->cache[i]);
 		free(self->cache);
 		self->cache = NULL;
 	}
@@ -1032,10 +1028,8 @@
 		nt_insert(self, PyString_AS_STRING(node), -1);
 	}
 
-	if (start == 0) {
-		Py_DECREF(self->added);
-		self->added = NULL;
-	}
+	if (start == 0)
+		Py_CLEAR(self->added);
 }
 
 /*


More information about the Mercurial-devel mailing list