[Python-Dev] PyMem_Realloc corner case

Jason Orendorff jason@jorendorff.com
Fri, 1 Mar 2002 00:15:15 -0600


I just got bit by the following:

On Windows, PyMem_Realloc() doesn't seem to work as advertised in
  http://www.python.org/doc/current/api/memoryInterface.html

In particular, "if n is equal to zero, the memory block is
resized but is not freed, and the returned pointer is non-NULL".

In Objects/object.c, lines 1878-1896, PyMem_Malloc() and
PyMem_Realloc() seem to try to guarantee this behavior.
Somehow it isn't working for me.

Does this mean MALLOC_ZERO_RETURNS_NULL should be defined
in PC/pyconfig.h?  Or do I have an off version of the CRT
that causes problems nobody else has <sigh>?

## Jason Orendorff    http://www.jorendorff.com/