[Python-checkins] r54532 - in python/branches/release25-maint: Misc/NEWS Modules/_ctypes/cfield.c
thomas.heller
python-checkins at python.org
Thu Mar 22 20:43:43 CET 2007
Author: thomas.heller
Date: Thu Mar 22 20:43:37 2007
New Revision: 54532
Modified:
python/branches/release25-maint/Misc/NEWS
python/branches/release25-maint/Modules/_ctypes/cfield.c
Log:
Back out "Patch #1643874: memory leak in ctypes fixed."
The code in this patch leaves no way to give up the ownership of a
BSTR instance.
Modified: python/branches/release25-maint/Misc/NEWS
==============================================================================
--- python/branches/release25-maint/Misc/NEWS (original)
+++ python/branches/release25-maint/Misc/NEWS Thu Mar 22 20:43:37 2007
@@ -287,8 +287,6 @@
- Bug #1643943: Fix %U handling for time.strptime.
-- Patch #1643874: memory leak in ctypes fixed.
-
- Bug #1598181: Avoid O(N**2) bottleneck in subprocess communicate().
- Patch #1627441: close sockets properly in urllib2.
Modified: python/branches/release25-maint/Modules/_ctypes/cfield.c
==============================================================================
--- python/branches/release25-maint/Modules/_ctypes/cfield.c (original)
+++ python/branches/release25-maint/Modules/_ctypes/cfield.c Thu Mar 22 20:43:37 2007
@@ -1424,19 +1424,10 @@
#endif
#ifdef MS_WIN32
-/* We cannot use SysFreeString as the PyCObject_FromVoidPtr
- because of different calling convention
-*/
-static void _my_SysFreeString(void *p)
-{
- SysFreeString((BSTR)p);
-}
-
static PyObject *
BSTR_set(void *ptr, PyObject *value, unsigned size)
{
BSTR bstr;
- PyObject *result;
/* convert value into a PyUnicodeObject or NULL */
if (Py_None == value) {
@@ -1464,19 +1455,15 @@
} else
bstr = NULL;
- if (bstr) {
- result = PyCObject_FromVoidPtr((void *)bstr, _my_SysFreeString);
- if (result == NULL) {
- SysFreeString(bstr);
- return NULL;
- }
- } else {
- result = Py_None;
- Py_INCREF(result);
- }
-
+ /* free the previous contents, if any */
+ if (*(BSTR *)ptr)
+ SysFreeString(*(BSTR *)ptr);
+
+ /* and store it */
*(BSTR *)ptr = bstr;
- return result;
+
+ /* We don't need to keep any other object */
+ _RET(value);
}
More information about the Python-checkins
mailing list