]> granicus.if.org Git - python/commit
_PyMalloc_{Malloc, Realloc}: Strive to meet the doc's promises about
authorTim Peters <tim.peters@gmail.com>
Thu, 4 Apr 2002 04:44:32 +0000 (04:44 +0000)
committerTim Peters <tim.peters@gmail.com>
Thu, 4 Apr 2002 04:44:32 +0000 (04:44 +0000)
commit84c1b974675b9252e1f5764a399ff9455fbf73e0
tree2a44ade5afd5e8535d582fe750520272ed93706c
parent243ea7166913a6cf9852373b2a3d965d6587477b
_PyMalloc_{Malloc, Realloc}:  Strive to meet the doc's promises about
what these do given a 0 size argument.  This is so that when pymalloc
is enabled, we don't need to wrap pymalloc calls in goofy little
routines special-casing 0.  Note that it's virtually impossible to meet
the doc's promise that malloc(0) will never return NULL; this makes a
best effort, but not an insane effort.  The code does promise that
realloc(not-NULL, 0) will never return NULL (malloc(0) is much harder).

_PyMalloc_Realloc:  Changed to take over all requests for 0 bytes, and
rearranged to be a little quicker in expected cases.

All over the place:  when resorting to the platform allocator, call
free/malloc/realloc directly, without indirecting thru macros.  This
should avoid needing a nightmarish pile of #ifdef-ery if PYMALLOC_DEBUG
is changed so that pymalloc takes over all Py(Mem, Object} memory
operations (which would add useful debugging info to PyMem_xyz
allocations too).
Objects/obmalloc.c