summaryrefslogtreecommitdiffstats
path: root/Objects/tupleobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-05-03 23:44:39 (GMT)
committerGuido van Rossum <guido@python.org>2000-05-03 23:44:39 (GMT)
commitb18618dab7b6b85bb05b084693706e59211fa180 (patch)
tree785d51f6677da8366be2ad4b4296a62f53161276 /Objects/tupleobject.c
parent2808b744e8d94459f189e1d89c97072d6a1f53b6 (diff)
downloadcpython-b18618dab7b6b85bb05b084693706e59211fa180.zip
cpython-b18618dab7b6b85bb05b084693706e59211fa180.tar.gz
cpython-b18618dab7b6b85bb05b084693706e59211fa180.tar.bz2
Vladimir Marangozov's long-awaited malloc restructuring.
For more comments, read the patches@python.org archives. For documentation read the comments in mymalloc.h and objimpl.h. (This is not exactly what Vladimir posted to the patches list; I've made a few changes, and Vladimir sent me a fix in private email for a problem that only occurs in debug mode. I'm also holding back on his change to main.c, which seems unnecessary to me.)
Diffstat (limited to 'Objects/tupleobject.c')
-rw-r--r--Objects/tupleobject.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index d1627a9..d5d6a07 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -80,10 +80,12 @@ PyTuple_New(size)
#ifdef COUNT_ALLOCS
fast_tuple_allocs++;
#endif
+ /* PyObject_InitVar is inlined */
#ifdef Py_TRACE_REFS
- op->ob_type = &PyTuple_Type;
op->ob_size = size;
+ op->ob_type = &PyTuple_Type;
#endif
+ _Py_NewReference((PyObject *)op);
}
else
#endif
@@ -96,17 +98,15 @@ PyTuple_New(size)
{
return PyErr_NoMemory();
}
- ;
- op = (PyTupleObject *) malloc(nbytes);
+ /* PyObject_NewVar is inlined */
+ op = (PyTupleObject *) PyObject_MALLOC(nbytes);
if (op == NULL)
return PyErr_NoMemory();
- op->ob_type = &PyTuple_Type;
- op->ob_size = size;
+ PyObject_INIT_VAR(op, &PyTuple_Type, size);
}
for (i = 0; i < size; i++)
op->ob_item[i] = NULL;
- _Py_NewReference((PyObject *)op);
#if MAXSAVESIZE > 0
if (size == 0) {
free_tuples[0] = op;
@@ -193,7 +193,7 @@ tupledealloc(op)
}
#endif
}
- free((ANY *)op);
+ PyObject_DEL(op);
done:
Py_TRASHCAN_SAFE_END(op)
}
@@ -530,11 +530,11 @@ _PyTuple_Resize(pv, newsize, last_is_sticky)
#endif
{
sv = (PyTupleObject *)
- realloc((char *)v,
+ PyObject_REALLOC((char *)v,
sizeof(PyTupleObject) + newsize * sizeof(PyObject *));
*pv = (PyObject *) sv;
if (sv == NULL) {
- PyMem_DEL(v);
+ PyObject_DEL(v);
PyErr_NoMemory();
return -1;
}
@@ -569,7 +569,7 @@ PyTuple_Fini()
while (p) {
q = p;
p = (PyTupleObject *)(p->ob_item[0]);
- PyMem_DEL(q);
+ PyObject_DEL(q);
}
}
#endif