[Python-checkins] CVS: python/dist/src/Objects object.c,2.155,2.156 typeobject.c,2.92,2.93

Tim Peters tim_one@users.sourceforge.net
Sat, 06 Oct 2001 20:54:53 -0700


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

Modified Files:
	object.c typeobject.c 
Log Message:
Guido suggests, and I agree, to insist that SIZEOF_VOID_P be a power of 2.
This simplifies the rounding in _PyObject_VAR_SIZE, allows to restore the
pre-rounding calling sequence, and allows some nice little simplifications
in its callers.  I'm still making it return a size_t, though.


Index: object.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v
retrieving revision 2.155
retrieving revision 2.156
diff -C2 -d -r2.155 -r2.156
*** object.c	2001/10/06 21:27:34	2.155
--- object.c	2001/10/07 03:54:51	2.156
***************
*** 131,137 ****
  {
  	PyVarObject *op;
! 	size_t size;
! 
! 	_PyObject_VAR_SIZE(size, tp, nitems);
  	op = (PyVarObject *) PyObject_MALLOC(size);
  	if (op == NULL)
--- 131,135 ----
  {
  	PyVarObject *op;
! 	const size_t size = _PyObject_VAR_SIZE(tp, nitems);
  	op = (PyVarObject *) PyObject_MALLOC(size);
  	if (op == NULL)
***************
*** 1159,1164 ****
  		return NULL;
  	if (dictoffset < 0) {
! 		size_t size;
! 		_PyObject_VAR_SIZE(size, tp, ((PyVarObject *)obj)->ob_size);
  		dictoffset += (long)size;
  		assert(dictoffset > 0);
--- 1157,1162 ----
  		return NULL;
  	if (dictoffset < 0) {
! 		const size_t size = _PyObject_VAR_SIZE(tp,
! 					((PyVarObject *)obj)->ob_size);
  		dictoffset += (long)size;
  		assert(dictoffset > 0);

Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.92
retrieving revision 2.93
diff -C2 -d -r2.92 -r2.93
*** typeobject.c	2001/10/06 21:27:34	2.92
--- typeobject.c	2001/10/07 03:54:51	2.93
***************
*** 192,198 ****
  {
  	PyObject *obj;
! 	size_t size;
! 
! 	_PyObject_VAR_SIZE(size, type, nitems);
  
  	if (PyType_IS_GC(type))
--- 192,196 ----
  {
  	PyObject *obj;
! 	const size_t size = _PyObject_VAR_SIZE(type, nitems);
  
  	if (PyType_IS_GC(type))