[Python-checkins] python/dist/src/Objects object.c,2.171,2.172

tim_one@sourceforge.net tim_one@sourceforge.net
Fri, 12 Apr 2002 00:22:58 -0700


Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv31971/python/Objects

Modified Files:
	object.c 
Log Message:
First stab at rationalizing the PyMem_ API.  Mixing PyObject_xyz with
PyMem_{Del, DEL} doesn't work yet (compilation problems).

pyport.h:  _PyMem_EXTRA is gone.

pmem.h:  Repaired comments.  PyMem_{Malloc, MALLOC} and
PyMem_{Realloc, REALLOC} now make the same x-platform guarantees when
asking for 0 bytes, and when passing a NULL pointer to the latter.

object.c:  PyMem_{Malloc, Realloc} just call their macro versions
now, since the latter take care of the x-platform 0 and NULL stuff
by themselves now.

pypcre.c, grow_stack():  So sue me.  On two lines, this called
PyMem_RESIZE to grow a "const" area.  It's not legit to realloc a
const area, so the compiler warned given the new expansion of
PyMem_RESIZE.  It would have gotten the same warning before if it
had used PyMem_Resize() instead; the older macro version, but not the
function version, silently cast away the constness.  IMO that was a wrong
thing to do, and the docs say the macro versions of PyMem_xyz are
deprecated anyway.  If somebody else is resizing const areas with the
macro spelling, they'll get a warning when they recompile now too.


Index: object.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v
retrieving revision 2.171
retrieving revision 2.172
diff -C2 -d -r2.171 -r2.172
*** object.c	12 Apr 2002 03:08:42 -0000	2.171
--- object.c	12 Apr 2002 07:22:56 -0000	2.172
***************
*** 1898,1905 ****
  PyMem_Malloc(size_t nbytes)
  {
- #if _PyMem_EXTRA > 0
- 	if (nbytes == 0)
- 		nbytes = _PyMem_EXTRA;
- #endif
  	return PyMem_MALLOC(nbytes);
  }
--- 1898,1901 ----
***************
*** 1908,1913 ****
  PyMem_Realloc(void *p, size_t nbytes)
  {
! 	/* See comment near MALLOC_ZERO_RETURNS_NULL in pyport.h. */
! 	return PyMem_REALLOC(p, nbytes ? nbytes : 1);
  }
  
--- 1904,1908 ----
  PyMem_Realloc(void *p, size_t nbytes)
  {
! 	return PyMem_REALLOC(p, nbytes);
  }