[Python-checkins] r45535 - python/trunk/Modules/_ctypes/_ctypes.c

thomas.heller python-checkins at python.org
Tue Apr 18 16:57:40 CEST 2006


Author: thomas.heller
Date: Tue Apr 18 16:57:39 2006
New Revision: 45535

Modified:
   python/trunk/Modules/_ctypes/_ctypes.c
Log:
Fix refcounting.
This makes 'import ctypes; reload(ctypes)' no longer leak reference counts.

Modified: python/trunk/Modules/_ctypes/_ctypes.c
==============================================================================
--- python/trunk/Modules/_ctypes/_ctypes.c	(original)
+++ python/trunk/Modules/_ctypes/_ctypes.c	Tue Apr 18 16:57:39 2006
@@ -1283,6 +1283,7 @@
 		suffix = PyString_FromString("_be");
 #endif
 
+	Py_INCREF(name);
 	PyString_Concat(&name, suffix);
 	if (name == NULL)
 		return NULL;
@@ -1459,6 +1460,7 @@
 		PyObject_SetAttrString(swapped, "__ctype_le__", (PyObject *)result);
 		PyObject_SetAttrString(swapped, "__ctype_be__", swapped);
 #endif
+		Py_DECREF(swapped);
 	};
 
 	return (PyObject *)result;


More information about the Python-checkins mailing list