From: Guido van Rossum Date: Tue, 5 Aug 1997 02:16:08 +0000 (+0000) Subject: Added _Fini() routines to free up some memory X-Git-Tag: v1.5a3~142 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fbbd57e4ca4250e27b564d989a75caa0b1a4a9b5;p=python Added _Fini() routines to free up some memory --- diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 7f7f50786b..6f5b625c4c 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -590,3 +590,9 @@ PyTypeObject PyFloat_Type = { 0, /*tp_as_mapping*/ (hashfunc)float_hash, /*tp_hash*/ }; + +void +PyFloat_Fini() +{ + /* XXX Alas, the free list is not easily and safely freeable */ +} diff --git a/Objects/intobject.c b/Objects/intobject.c index 4db2a69bab..e09758be58 100644 --- a/Objects/intobject.c +++ b/Objects/intobject.c @@ -790,3 +790,20 @@ PyTypeObject PyInt_Type = { 0, /*tp_as_mapping*/ (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 */ +} diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index 7dc4dc8370..0faedb480a 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -74,7 +74,8 @@ PyTuple_New(size) #ifdef COUNT_ALLOCS fast_tuple_allocs++; #endif - } else + } + else #endif { op = (PyTupleObject *) malloc( @@ -467,3 +468,25 @@ _PyTuple_Resize(pv, newsize, last_is_sticky) sv->ob_size = newsize; 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 +}