[Python-checkins] CVS: python/dist/src/Modules gcmodule.c,2.22,2.23

Tim Peters tim_one@users.sourceforge.net
2001年10月06日 20:54:53 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv14609/python/Modules
Modified Files:
	gcmodule.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: gcmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v
retrieving revision 2.22
retrieving revision 2.23
diff -C2 -d -r2.22 -r2.23
*** gcmodule.c	2001年10月06日 21:27:34	2.22
--- gcmodule.c	2001年10月07日 03:54:51	2.23
***************
*** 802,813 ****
 {
 	PyObject *op;
! 	size_t basicsize;
 #ifdef WITH_CYCLE_GC
! 	size_t nbytes;
! 	PyGC_Head *g;
! 
! 	_PyObject_VAR_SIZE(basicsize, tp, nitems);
! 	nbytes = sizeof(PyGC_Head) + basicsize;
! 	g = PyObject_MALLOC(nbytes);
 	if (g == NULL)
 		return (PyObject *)PyErr_NoMemory();
--- 802,809 ----
 {
 	PyObject *op;
! 	const size_t basicsize = _PyObject_VAR_SIZE(tp, nitems);
 #ifdef WITH_CYCLE_GC
! 	const size_t nbytes = sizeof(PyGC_Head) + basicsize;
! 	PyGC_Head *g = PyObject_MALLOC(nbytes);
 	if (g == NULL)
 		return (PyObject *)PyErr_NoMemory();
***************
*** 825,829 ****
 	op = FROM_GC(g);
 #else
- 	_PyObject_VAR_SIZE(basicsize, tp, nitems);
 	op = PyObject_MALLOC(basicsize);
 	if (op == NULL)
--- 821,824 ----
***************
*** 851,859 ****
 _PyObject_GC_Resize(PyVarObject *op, int nitems)
 {
! 	size_t basicsize;
 #ifdef WITH_CYCLE_GC
 	PyGC_Head *g = AS_GC(op);
- 
- 	_PyObject_VAR_SIZE(basicsize, op->ob_type, nitems);
 	g = PyObject_REALLOC(g, sizeof(PyGC_Head) + basicsize);
 	if (g == NULL)
--- 846,852 ----
 _PyObject_GC_Resize(PyVarObject *op, int nitems)
 {
! 	const size_t basicsize = _PyObject_VAR_SIZE(op->ob_type, nitems);
 #ifdef WITH_CYCLE_GC
 	PyGC_Head *g = AS_GC(op);
 	g = PyObject_REALLOC(g, sizeof(PyGC_Head) + basicsize);
 	if (g == NULL)
***************
*** 861,865 ****
 	op = (PyVarObject *) FROM_GC(g);
 #else
- 	_PyObject_VAR_SIZE(basicsize, op->ob_type, nitems);
 	op = PyObject_REALLOC(op, basicsize);
 	if (op == NULL)
--- 854,857 ----

AltStyle によって変換されたページ (->オリジナル) /