summaryrefslogtreecommitdiffstats
path: root/Objects/tupleobject.c
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2000-06-23 19:37:02 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2000-06-23 19:37:02 (GMT)
commitd08b4c4524a31695d7e63768c02f472c9cb54fbd (patch)
treeb81cade431fa30d6446fef0122a3796b0876c8a2 /Objects/tupleobject.c
parentd22162bac7e42ccf90571ee2607c9c42ed2df3fe (diff)
downloadcpython-d08b4c4524a31695d7e63768c02f472c9cb54fbd.zip
cpython-d08b4c4524a31695d7e63768c02f472c9cb54fbd.tar.gz
cpython-d08b4c4524a31695d7e63768c02f472c9cb54fbd.tar.bz2
part 2 of Neil Schemenauer's GC patches:
This patch modifies the type structures of objects that participate in GC. The object's tp_basicsize is increased when GC is enabled. GC information is prefixed to the object to maintain binary compatibility. GC objects also define the tp_flag Py_TPFLAGS_GC.
Diffstat (limited to 'Objects/tupleobject.c')
-rw-r--r--Objects/tupleobject.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index bbb56b1..73e3304 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -93,7 +93,8 @@ PyTuple_New(size)
int nbytes = size * sizeof(PyObject *);
/* Check for overflow */
if (nbytes / sizeof(PyObject *) != (size_t)size ||
- (nbytes += sizeof(PyTupleObject) - sizeof(PyObject *))
+ (nbytes += sizeof(PyTupleObject) - sizeof(PyObject *)
+ + PyGC_INFO_SIZE)
<= 0)
{
return PyErr_NoMemory();
@@ -452,7 +453,7 @@ PyTypeObject PyTuple_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
"tuple",
- sizeof(PyTupleObject) - sizeof(PyObject *),
+ sizeof(PyTupleObject) - sizeof(PyObject *) + PyGC_INFO_SIZE,
sizeof(PyObject *),
(destructor)tupledealloc, /*tp_dealloc*/
(printfunc)tupleprint, /*tp_print*/
@@ -469,7 +470,7 @@ PyTypeObject PyTuple_Type = {
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /*tp_flags*/
0, /*tp_doc*/
(traverseproc)tupletraverse, /* tp_traverse */
};
@@ -557,8 +558,9 @@ _PyTuple_Resize(pv, newsize, last_is_sticky)
#endif
{
sv = (PyTupleObject *)
- PyObject_REALLOC((char *)v,
- sizeof(PyTupleObject) + newsize * sizeof(PyObject *));
+ PyObject_REALLOC((char *)v, sizeof(PyTupleObject)
+ + PyGC_INFO_SIZE
+ + newsize * sizeof(PyObject *));
*pv = (PyObject *) sv;
if (sv == NULL) {
PyObject_DEL(v);