summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2007-03-22 20:33:04 (GMT)
committerThomas Heller <theller@ctypes.org>2007-03-22 20:33:04 (GMT)
commit50d1d0bad5a6dc7136a6f95eb6763e5cc8162da7 (patch)
treea261247e4b7b8eb58ff93b64bde80876a852c3c6
parent02b8feea9f6974de89fcd1888ef5326d436a7d0a (diff)
downloadcpython-50d1d0bad5a6dc7136a6f95eb6763e5cc8162da7.zip
cpython-50d1d0bad5a6dc7136a6f95eb6763e5cc8162da7.tar.gz
cpython-50d1d0bad5a6dc7136a6f95eb6763e5cc8162da7.tar.bz2
Explain the purpose of the b_needsfree flag. This answers Neals
question (well, two months too late).
-rw-r--r--Modules/_ctypes/_ctypes.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 5306456..941da0b 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -2181,7 +2181,12 @@ static void CData_MallocBuffer(CDataObject *obj, StgDictObject *dict)
if ((size_t)dict->size <= sizeof(obj->b_value)) {
/* No need to call malloc, can use the default buffer */
obj->b_ptr = (char *)&obj->b_value;
- /* XXX(nnorwitz): shouldn't b_needsfree be 0? */
+ /* The b_needsfree flag does not mean that we actually did
+ call PyMem_Malloc to allocate the memory block; instead it
+ means we are the *owner* of the memory and are responsible
+ for freeing resources associated with the memory. This is
+ also the reason that b_needsfree is exposed to Python.
+ */
obj->b_needsfree = 1;
} else {
/* In python 2.4, and ctypes 0.9.6, the malloc call took about