[Python-checkins] CVS: python/dist/src/Objects typeobject.c,2.123,2.124

Guido van Rossum gvanrossum@users.sourceforge.net
Wed, 05 Dec 2001 18:36:00 -0800


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

Modified Files:
	typeobject.c 
Log Message:
The previous checkin to clear __slots__ variables did a little bit of
the work each time it found another base class.  All the work is
contiguous, so we might as well do it all at once at the end.


Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.123
retrieving revision 2.124
diff -C2 -d -r2.123 -r2.124
*** typeobject.c	2001/12/05 22:45:48	2.123
--- typeobject.c	2001/12/06 02:35:58	2.124
***************
*** 305,309 ****
  subtype_dealloc(PyObject *self)
  {
! 	PyTypeObject *type, *base, *temp;
  	destructor f;
  
--- 305,309 ----
  subtype_dealloc(PyObject *self)
  {
! 	PyTypeObject *type, *base;
  	destructor f;
  
***************
*** 315,340 ****
  	/* Find the nearest base with a different tp_dealloc */
  	type = self->ob_type;
! 	base = type;
  	while ((f = base->tp_dealloc) == subtype_dealloc) {
- 		temp = base;
  		base = base->tp_base;
  		assert(base);
! 		/* While we're at it, clear __slots__ variables */
! 		if (temp->tp_basicsize != base->tp_basicsize &&
! 		    temp->tp_itemsize == 0)
! 		{
! 			char *addr = ((char *)self);
! 			char *p = addr + base->tp_basicsize;
! 			char *q = addr + temp->tp_basicsize;
! 			for (; p < q; p += sizeof(PyObject *)) {
! 				PyObject **pp;
! 				if (p == addr + type->tp_dictoffset ||
! 				    p == addr + type->tp_weaklistoffset)
! 					continue;
! 				pp = (PyObject **)p;
! 				if (*pp != NULL) {
! 					Py_DECREF(*pp);
! 					*pp = NULL;
! 				}
  			}
  		}
--- 315,340 ----
  	/* Find the nearest base with a different tp_dealloc */
  	type = self->ob_type;
! 	base = type->tp_base;
  	while ((f = base->tp_dealloc) == subtype_dealloc) {
  		base = base->tp_base;
  		assert(base);
! 	}
! 
! 	/* Clear __slots__ variables */
! 	if (type->tp_basicsize != base->tp_basicsize &&
! 	    type->tp_itemsize == 0)
! 	{
! 		char *addr = ((char *)self);
! 		char *p = addr + base->tp_basicsize;
! 		char *q = addr + type->tp_basicsize;
! 		for (; p < q; p += sizeof(PyObject *)) {
! 			PyObject **pp;
! 			if (p == addr + type->tp_dictoffset ||
! 			    p == addr + type->tp_weaklistoffset)
! 				continue;
! 			pp = (PyObject **)p;
! 			if (*pp != NULL) {
! 				Py_DECREF(*pp);
! 				*pp = NULL;
  			}
  		}