[Python-checkins] python/dist/src/Include object.h,2.126,2.127

dcjim at users.sourceforge.net dcjim at users.sourceforge.net
Wed Jul 14 21:08:07 CEST 2004


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

Modified Files:
	object.h 
Log Message:
Implemented a new Py_CLEAR macro. This macro should be used when 
decrementing the refcount of variables that might be accessed as a
result of calling Python


Index: object.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/object.h,v
retrieving revision 2.126
retrieving revision 2.127
diff -C2 -d -r2.126 -r2.127
*** object.h	22 Apr 2004 17:23:30 -0000	2.126
--- object.h	14 Jul 2004 19:07:35 -0000	2.127
***************
*** 621,624 ****
--- 621,633 ----
  		_Py_Dealloc((PyObject *)(op))
  
+ #define Py_CLEAR(op)				\
+         do {                            	\
+                 if (op) {			\
+                         PyObject *tmp = (op);	\
+                         (op) = NULL;		\
+                         Py_DECREF(tmp);		\
+                 }				\
+         } while (0)
+ 
  /* Macros to use in case the object pointer may be NULL: */
  #define Py_XINCREF(op) if ((op) == NULL) ; else Py_INCREF(op)



More information about the Python-checkins mailing list