[Python-checkins] python/dist/src/Objects obmalloc.c,2.51,2.52

nnorwitz at users.sourceforge.net nnorwitz at users.sourceforge.net
Sun Jun 6 15:20:25 EDT 2004


Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv604/Objects

Modified Files:
	obmalloc.c 
Log Message:
SF bug 881641, make it easier to use valgrind

Index: obmalloc.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v
retrieving revision 2.51
retrieving revision 2.52
diff -C2 -d -r2.51 -r2.52
*** obmalloc.c	17 Jun 2003 15:48:11 -0000	2.51
--- obmalloc.c	6 Jun 2004 19:20:22 -0000	2.52
***************
*** 535,540 ****
   * a NULL arenas.
   */
! #define ADDRESS_IN_RANGE(P, I) \
! 	((I) < narenas && (uptr)(P) - arenas[I] < (uptr)ARENA_SIZE)
  
  /*==========================================================================*/
--- 535,564 ----
   * a NULL arenas.
   */
! #define Py_ADDRESS_IN_RANGE(P, POOL)	\
! 	((POOL)->arenaindex < narenas &&		\
! 	 (uptr)(P) - arenas[(POOL)->arenaindex] < (uptr)ARENA_SIZE)
! 
! /* This is only useful when running memory debuggers such as
!  * Purify or Valgrind.  Uncomment to use.
!  *
!  */
! #define Py_USING_MEMORY_DEBUGGER
! 
! #ifdef Py_USING_MEMORY_DEBUGGER
! 
! /* Py_ADDRESS_IN_RANGE may access uninitialized memory by design
!  * This leads to thousands of spurious warnings when using
!  * Purify or Valgrind.  By making a function, we can easily
!  * suppress the uninitialized memory reads in this one function.
!  * So we won't ignore real errors elsewhere.
!  *
!  * Disable the macro and use a function.
!  */
! 
! #undef Py_ADDRESS_IN_RANGE
! 
! /* Don't make static, to ensure this isn't inlined. */
! int Py_ADDRESS_IN_RANGE(void *P, poolp pool);
! #endif
  
  /*==========================================================================*/
***************
*** 709,713 ****
  
  	pool = POOL_ADDR(p);
! 	if (ADDRESS_IN_RANGE(p, pool->arenaindex)) {
  		/* We allocated this address. */
  		LOCK();
--- 733,737 ----
  
  	pool = POOL_ADDR(p);
! 	if (Py_ADDRESS_IN_RANGE(p, pool)) {
  		/* We allocated this address. */
  		LOCK();
***************
*** 792,796 ****
  
  	pool = POOL_ADDR(p);
! 	if (ADDRESS_IN_RANGE(p, pool->arenaindex)) {
  		/* We're in charge of this block */
  		size = INDEX2SIZE(pool->szidx);
--- 816,820 ----
  
  	pool = POOL_ADDR(p);
! 	if (Py_ADDRESS_IN_RANGE(p, pool)) {
  		/* We're in charge of this block */
  		size = INDEX2SIZE(pool->szidx);
***************
*** 1374,1375 ****
--- 1398,1410 ----
  
  #endif	/* PYMALLOC_DEBUG */
+ 
+ #ifdef Py_USING_MEMORY_DEBUGGER
+ /* Make this function last so gcc won't inline it
+    since the definition is after the reference. */
+ int
+ Py_ADDRESS_IN_RANGE(void *P, poolp pool)
+ {
+ 	return ((pool->arenaindex) < narenas &&
+ 		(uptr)(P) - arenas[pool->arenaindex] < (uptr)ARENA_SIZE);
+ }
+ #endif




More information about the Python-checkins mailing list