summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2007-03-22 20:34:37 (GMT)
committerThomas Heller <theller@ctypes.org>2007-03-22 20:34:37 (GMT)
commit82730f8d11050a567c6db88c91e7d788d8048e09 (patch)
tree69578f49cd3c21845ad7262124bdf88cc867ad16 /Modules
parentf493cbd8248650e14422ea04e1c3953fdcacd218 (diff)
downloadcpython-82730f8d11050a567c6db88c91e7d788d8048e09.zip
cpython-82730f8d11050a567c6db88c91e7d788d8048e09.tar.gz
cpython-82730f8d11050a567c6db88c91e7d788d8048e09.tar.bz2
Explain the purpose of the b_needsfree flag (forward ported from release25-maint).
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/_ctypes.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index cce16ca..cfff1a9 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -2181,6 +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;
+ /* 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