[Python-checkins] python/dist/src/Objects object.c,2.184,2.185

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Mon, 08 Jul 2002 19:57:03 -0700


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

Modified Files:
	object.c 
Log Message:
The Py_REF_DEBUG/COUNT_ALLOCS/Py_TRACE_REFS macro minefield:  added
more trivial lexical helper macros so that uses of these guys expand
to nothing at all when they're not enabled.  This should help sub-
standard compilers that can't do a good job of optimizing away the
previous "(void)0" expressions.

Py_DECREF:  There's only one definition of this now.  Yay!  That
was that last one in the family defined multiple times in an #ifdef
maze.

Py_FatalError():  Changed the char* signature to const char*.

_Py_NegativeRefcount():  New helper function for the Py_REF_DEBUG
expansion of Py_DECREF.  Calling an external function cuts down on
the volume of generated code.  The previous inline expansion of abort()
didn't work as intended on Windows (the program often kept going, and
the error msg scrolled off the screen unseen).  _Py_NegativeRefcount
calls Py_FatalError instead, which captures our best knowledge of
how to abort effectively across platforms.


Index: object.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v
retrieving revision 2.184
retrieving revision 2.185
diff -C2 -d -r2.184 -r2.185
*** object.c	8 Jul 2002 22:11:52 -0000	2.184
--- object.c	9 Jul 2002 02:57:01 -0000	2.185
***************
*** 92,95 ****
--- 92,110 ----
  #endif
  
+ #ifdef Py_REF_DEBUG
+ /* Log a fatal error; doesn't return. */
+ void
+ _Py_NegativeRefcount(const char *fname, int lineno, PyObject *op)
+ {
+ 	char buf[300];
+ 
+ 	PyOS_snprintf(buf, sizeof(buf),
+ 		      "%s:%i object at %p has negative ref count %i",
+ 		      fname, lineno, op, op->ob_refcnt);
+ 	Py_FatalError(buf);
+ }
+ 
+ #endif /* Py_REF_DEBUG */
+ 
  PyObject *
  PyObject_Init(PyObject *op, PyTypeObject *tp)