Restored revision 2.87.
This commit is contained in:
parent
8d9b60f102
commit
6fce78e07f
|
@ -27,7 +27,7 @@ PyObject *
|
||||||
PyTuple_New(register int size)
|
PyTuple_New(register int size)
|
||||||
{
|
{
|
||||||
register PyTupleObject *op;
|
register PyTupleObject *op;
|
||||||
|
int i;
|
||||||
if (size < 0) {
|
if (size < 0) {
|
||||||
PyErr_BadInternalCall();
|
PyErr_BadInternalCall();
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -68,8 +68,9 @@ PyTuple_New(register int size)
|
||||||
op = PyObject_GC_NewVar(PyTupleObject, &PyTuple_Type, size);
|
op = PyObject_GC_NewVar(PyTupleObject, &PyTuple_Type, size);
|
||||||
if (op == NULL)
|
if (op == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
memset(op->ob_item, 0, size*sizeof(PyObject*));
|
|
||||||
}
|
}
|
||||||
|
for (i=0; i < size; i++)
|
||||||
|
op->ob_item[i] = NULL;
|
||||||
#if MAXSAVESIZE > 0
|
#if MAXSAVESIZE > 0
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
free_tuples[0] = op;
|
free_tuples[0] = op;
|
||||||
|
@ -164,27 +165,19 @@ tupledealloc(register PyTupleObject *op)
|
||||||
Py_TRASHCAN_SAFE_BEGIN(op)
|
Py_TRASHCAN_SAFE_BEGIN(op)
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
i = len;
|
i = len;
|
||||||
|
while (--i >= 0)
|
||||||
|
Py_XDECREF(op->ob_item[i]);
|
||||||
#if MAXSAVESIZE > 0
|
#if MAXSAVESIZE > 0
|
||||||
if (len < MAXSAVESIZE &&
|
if (len < MAXSAVESIZE &&
|
||||||
num_free_tuples[len] < MAXSAVEDTUPLES &&
|
num_free_tuples[len] < MAXSAVEDTUPLES &&
|
||||||
op->ob_type == &PyTuple_Type)
|
op->ob_type == &PyTuple_Type)
|
||||||
{
|
{
|
||||||
while (--i >= 0) {
|
|
||||||
PyObject* o = op->ob_item[i];
|
|
||||||
if (o != NULL) {
|
|
||||||
op->ob_item[i] = NULL;
|
|
||||||
Py_DECREF(o);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
op->ob_item[0] = (PyObject *) free_tuples[len];
|
op->ob_item[0] = (PyObject *) free_tuples[len];
|
||||||
num_free_tuples[len]++;
|
num_free_tuples[len]++;
|
||||||
free_tuples[len] = op;
|
free_tuples[len] = op;
|
||||||
goto done; /* return */
|
goto done; /* return */
|
||||||
}
|
}
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
while (--i >= 0)
|
|
||||||
Py_XDECREF(op->ob_item[i]);
|
|
||||||
}
|
}
|
||||||
op->ob_type->tp_free((PyObject *)op);
|
op->ob_type->tp_free((PyObject *)op);
|
||||||
done:
|
done:
|
||||||
|
|
Loading…
Reference in New Issue