From fb09f0e85cd75ec46700562687a9da3063ff0b7c Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Thu, 7 Oct 2004 03:58:07 +0000 Subject: [PATCH] Finalize the freelist of list objects. --- Include/pythonrun.h | 1 + Objects/listobject.c | 13 +++++++++++++ Python/pythonrun.c | 1 + 3 files changed, 15 insertions(+) diff --git a/Include/pythonrun.h b/Include/pythonrun.h index 145c009303b..33497ceafca 100644 --- a/Include/pythonrun.h +++ b/Include/pythonrun.h @@ -113,6 +113,7 @@ PyAPI_FUNC(void) PyMethod_Fini(void); PyAPI_FUNC(void) PyFrame_Fini(void); PyAPI_FUNC(void) PyCFunction_Fini(void); PyAPI_FUNC(void) PyTuple_Fini(void); +PyAPI_FUNC(void) PyList_Fini(void); PyAPI_FUNC(void) PyString_Fini(void); PyAPI_FUNC(void) PyInt_Fini(void); PyAPI_FUNC(void) PyFloat_Fini(void); diff --git a/Objects/listobject.c b/Objects/listobject.c index 44616e56a03..08ab0951c9b 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -68,6 +68,19 @@ list_resize(PyListObject *self, int newsize) static PyListObject *free_lists[MAXFREELISTS]; static int num_free_lists = 0; +void +PyList_Fini(void) +{ + PyListObject *op; + + while (num_free_lists) { + num_free_lists--; + op = free_lists[num_free_lists]; + assert(PyList_CheckExact(op)); + PyObject_GC_Del(op); + } +} + PyObject * PyList_New(int size) { diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 917f2be00b0..06bec1e0386 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -416,6 +416,7 @@ Py_Finalize(void) PyFrame_Fini(); PyCFunction_Fini(); PyTuple_Fini(); + PyList_Fini(); PyString_Fini(); PyInt_Fini(); PyFloat_Fini();