]> granicus.if.org Git - python/commitdiff
Explain the purpose of the b_needsfree flag (forward ported from release25-maint).
authorThomas Heller <theller@ctypes.org>
Thu, 22 Mar 2007 20:34:37 +0000 (20:34 +0000)
committerThomas Heller <theller@ctypes.org>
Thu, 22 Mar 2007 20:34:37 +0000 (20:34 +0000)
Modules/_ctypes/_ctypes.c

index cce16ca53bef665f703073edddcbee10680669c3..cfff1a96383b733fef921e1ac42032257cbbc8b6 100644 (file)
@@ -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