Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fbbd57e

Browse files
committed
Added _Fini() routines to free up some memory
1 parent 971a7aa commit fbbd57e

3 files changed

Lines changed: 47 additions & 1 deletion

File tree

Objects/floatobject.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,3 +590,9 @@ PyTypeObject PyFloat_Type = {
590590
0, /*tp_as_mapping*/
591591
(hashfunc)float_hash, /*tp_hash*/
592592
};
593+
594+
void
595+
PyFloat_Fini()
596+
{
597+
/* XXX Alas, the free list is not easily and safely freeable */
598+
}

Objects/intobject.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,3 +790,20 @@ PyTypeObject PyInt_Type = {
790790
0, /*tp_as_mapping*/
791791
(hashfunc)int_hash, /*tp_hash*/
792792
};
793+
794+
void
795+
PyInt_Fini()
796+
{
797+
#if NSMALLNEGINTS + NSMALLPOSINTS > 0
798+
int i;
799+
PyIntObject **p;
800+
801+
i = NSMALLNEGINTS + NSMALLPOSINTS;
802+
p = small_ints;
803+
while (--i >= 0) {
804+
Py_XDECREF(*p);
805+
*p++ = NULL;
806+
}
807+
#endif
808+
/* XXX Alas, the free list is not easily and safely freeable */
809+
}

Objects/tupleobject.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ PyTuple_New(size)
7474
#ifdef COUNT_ALLOCS
7575
fast_tuple_allocs++;
7676
#endif
77-
} else
77+
}
78+
else
7879
#endif
7980
{
8081
op = (PyTupleObject *) malloc(
@@ -467,3 +468,25 @@ _PyTuple_Resize(pv, newsize, last_is_sticky)
467468
sv->ob_size = newsize;
468469
return 0;
469470
}
471+
472+
void
473+
PyTuple_Fini()
474+
{
475+
#if MAXSAVESIZE > 0
476+
int i;
477+
478+
Py_XDECREF(free_tuples[0]);
479+
free_tuples[0] = NULL;
480+
481+
for (i = 1; i < MAXSAVESIZE; i++) {
482+
PyTupleObject *p, *q;
483+
p = free_tuples[i];
484+
free_tuples[i] = NULL;
485+
while (p) {
486+
q = p;
487+
p = (PyTupleObject *)(p->ob_item[0]);
488+
PyMem_DEL(q);
489+
}
490+
}
491+
#endif
492+
}

0 commit comments

Comments
 (0)