[Python-checkins] r54537 - python/branches/release25-maint/Modules/_ctypes/_ctypes.c

thomas.heller python-checkins at python.org
Thu Mar 22 21:33:10 CET 2007


Author: thomas.heller
Date: Thu Mar 22 21:33:04 2007
New Revision: 54537

Modified:
   python/branches/release25-maint/Modules/_ctypes/_ctypes.c
Log:
Explain the purpose of the b_needsfree flag.  This answers Neals
question (well, two months too late).


Modified: python/branches/release25-maint/Modules/_ctypes/_ctypes.c
==============================================================================
--- python/branches/release25-maint/Modules/_ctypes/_ctypes.c	(original)
+++ python/branches/release25-maint/Modules/_ctypes/_ctypes.c	Thu Mar 22 21:33:04 2007
@@ -2181,7 +2181,12 @@
 	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


More information about the Python-checkins mailing list