[Python-checkins] CVS: python/dist/src/Objects object.c,2.162,2.162.6.1

Michael Hudson mwh@users.sourceforge.net
Tue, 05 Mar 2002 06:23:58 -0800


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

Modified Files:
      Tag: release22-maint
	object.c 
Log Message:
backport tim_one's checkin of
    revision 2.164 of object.c

Whether platform malloc(0) returns NULL has nothing to do with whether
platform realloc(p, 0) returns NULL, so MALLOC_ZERO_RETURNS_NULL can
be correctly undefined yet realloc(p, 0) can return NULL anyway.

Prevent realloc(p, 0) doing free(p) and returning NULL via a different
hack.  Would probably be better to get rid of MALLOC_ZERO_RETURNS_NULL
entirely.

Bugfix candidate.


Index: object.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v
retrieving revision 2.162
retrieving revision 2.162.6.1
diff -C2 -d -r2.162 -r2.162.6.1
*** object.c	4 Dec 2001 15:54:53 -0000	2.162
--- object.c	5 Mar 2002 14:23:56 -0000	2.162.6.1
***************
*** 1889,1897 ****
  PyMem_Realloc(void *p, size_t nbytes)
  {
! #if _PyMem_EXTRA > 0
! 	if (nbytes == 0)
! 		nbytes = _PyMem_EXTRA;
! #endif
! 	return PyMem_REALLOC(p, nbytes);
  }
  
--- 1889,1894 ----
  PyMem_Realloc(void *p, size_t nbytes)
  {
! 	/* See comment near MALLOC_ZERO_RETURNS_NULL in pyport.h. */
! 	return PyMem_REALLOC(p, nbytes ? nbytes : 1);
  }