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

Guido van Rossum gvanrossum@users.sourceforge.net
Tue, 19 Jun 2001 07:14:02 -0700


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

Modified Files:
      Tag: descr-branch
	typeobject.c 
Log Message:
Support for the tp_free slot: object_dealloc and type_dealloc now call
this.  Also, PyType_Type doesn't have to specify a value for tp_alloc,
that's inherited from PyBaseObject_Type.


Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.16.8.46
retrieving revision 2.16.8.47
diff -C2 -r2.16.8.46 -r2.16.8.47
*** typeobject.c	2001/06/18 22:21:42	2.16.8.46
--- typeobject.c	2001/06/19 14:14:00	2.16.8.47
***************
*** 557,564 ****
  	Py_XDECREF(type->tp_base);
  	Py_XDECREF(type->tp_dict);
  	Py_XDECREF(et->name);
  	Py_XDECREF(et->slots);
! 	/* XXX more, e.g. bases, mro, introduced ... */
! 	PyObject_DEL(type);
  }
  
--- 557,567 ----
  	Py_XDECREF(type->tp_base);
  	Py_XDECREF(type->tp_dict);
+ 	Py_XDECREF(type->tp_bases);
+ 	Py_XDECREF(type->tp_mro);
+ 	Py_XDECREF(type->tp_introduced);
+ 	/* XXX more? */
  	Py_XDECREF(et->name);
  	Py_XDECREF(et->slots);
! 	type->ob_type->tp_free((PyObject *)type);
  }
  
***************
*** 605,609 ****
  	offsetof(PyTypeObject, tp_dict),	/* tp_dictoffset */
  	0,					/* tp_init */
! 	PyType_GenericAlloc,			/* tp_alloc */
  	type_new,				/* tp_new */
  };
--- 608,612 ----
  	offsetof(PyTypeObject, tp_dict),	/* tp_dictoffset */
  	0,					/* tp_init */
! 	0,					/* tp_alloc */
  	type_new,				/* tp_new */
  };
***************
*** 621,624 ****
--- 624,633 ----
  object_dealloc(PyObject *self)
  {
+ 	self->ob_type->tp_free(self);
+ }
+ 
+ static void
+ object_free(PyObject *self)
+ {
  	PyObject_Del(self);
  }
***************
*** 669,672 ****
--- 678,682 ----
  	PyType_GenericAlloc,			/* tp_alloc */
  	PyType_GenericNew,			/* tp_new */
+ 	object_free,				/* tp_free */
  };
  
***************
*** 920,923 ****
--- 930,934 ----
  		COPYSLOT(tp_alloc);
  		COPYSLOT(tp_new);
+ 		COPYSLOT(tp_free);
  	}