[Python-checkins] python/dist/src/Objects obmalloc.c,2.41,2.42

tim_one@sourceforge.net tim_one@sourceforge.net
Thu, 18 Apr 2002 14:58:58 -0700


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

Modified Files:
	obmalloc.c 
Log Message:
PyObject_Malloc:  make a tiny bit faster for platforms where malloc(0)
doesn't return NULL.

PyObject_Realloc:  better comment for why we don't call PyObject_Malloc(0).


Index: obmalloc.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v
retrieving revision 2.41
retrieving revision 2.42
diff -C2 -d -r2.41 -r2.42
*** obmalloc.c	18 Apr 2002 21:37:03 -0000	2.41
--- obmalloc.c	18 Apr 2002 21:58:56 -0000	2.42
***************
*** 686,690 ****
  	 * has been reached.
  	 */
! 	return (void *)malloc(nbytes ? nbytes : 1);
  }
  
--- 686,694 ----
  	 * has been reached.
  	 */
! #ifdef MALLOC_ZERO_RETURNS_NULL
! 	if (nbytes == 0)
! 		nbytes = 1;
! #endif
! 	return (void *)malloc(nbytes);
  }
  
***************
*** 804,808 ****
  	/* We're not managing this block. */
  	if (nbytes <= SMALL_REQUEST_THRESHOLD) {
! 		/* Take over this block. */
  		bp = PyObject_Malloc(nbytes ? nbytes : 1);
  		if (bp != NULL) {
--- 808,815 ----
  	/* We're not managing this block. */
  	if (nbytes <= SMALL_REQUEST_THRESHOLD) {
! 		/* Take over this block -- ask for at least one byte so
! 		 * we really do take it over (PyObject_Malloc(0) goes to
! 		 * the system malloc).
! 		 */
  		bp = PyObject_Malloc(nbytes ? nbytes : 1);
  		if (bp != NULL) {