Kaydet (Commit) fbbd57e4 authored tarafından Guido van Rossum's avatar Guido van Rossum

Added _Fini() routines to free up some memory

üst 971a7aae
...@@ -590,3 +590,9 @@ PyTypeObject PyFloat_Type = { ...@@ -590,3 +590,9 @@ PyTypeObject PyFloat_Type = {
0, /*tp_as_mapping*/ 0, /*tp_as_mapping*/
(hashfunc)float_hash, /*tp_hash*/ (hashfunc)float_hash, /*tp_hash*/
}; };
void
PyFloat_Fini()
{
/* XXX Alas, the free list is not easily and safely freeable */
}
...@@ -790,3 +790,20 @@ PyTypeObject PyInt_Type = { ...@@ -790,3 +790,20 @@ PyTypeObject PyInt_Type = {
0, /*tp_as_mapping*/ 0, /*tp_as_mapping*/
(hashfunc)int_hash, /*tp_hash*/ (hashfunc)int_hash, /*tp_hash*/
}; };
void
PyInt_Fini()
{
#if NSMALLNEGINTS + NSMALLPOSINTS > 0
int i;
PyIntObject **p;
i = NSMALLNEGINTS + NSMALLPOSINTS;
p = small_ints;
while (--i >= 0) {
Py_XDECREF(*p);
*p++ = NULL;
}
#endif
/* XXX Alas, the free list is not easily and safely freeable */
}
...@@ -74,7 +74,8 @@ PyTuple_New(size) ...@@ -74,7 +74,8 @@ PyTuple_New(size)
#ifdef COUNT_ALLOCS #ifdef COUNT_ALLOCS
fast_tuple_allocs++; fast_tuple_allocs++;
#endif #endif
} else }
else
#endif #endif
{ {
op = (PyTupleObject *) malloc( op = (PyTupleObject *) malloc(
...@@ -467,3 +468,25 @@ _PyTuple_Resize(pv, newsize, last_is_sticky) ...@@ -467,3 +468,25 @@ _PyTuple_Resize(pv, newsize, last_is_sticky)
sv->ob_size = newsize; sv->ob_size = newsize;
return 0; return 0;
} }
void
PyTuple_Fini()
{
#if MAXSAVESIZE > 0
int i;
Py_XDECREF(free_tuples[0]);
free_tuples[0] = NULL;
for (i = 1; i < MAXSAVESIZE; i++) {
PyTupleObject *p, *q;
p = free_tuples[i];
free_tuples[i] = NULL;
while (p) {
q = p;
p = (PyTupleObject *)(p->ob_item[0]);
PyMem_DEL(q);
}
}
#endif
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment