summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2008-02-14 12:47:33 (GMT)
committerChristian Heimes <christian@cheimes.de>2008-02-14 12:47:33 (GMT)
commit3b718a79af900fdacaf0b825137f69eadc753765 (patch)
tree71cbe9fcb7b94a2611e5f62cf329285270615e22 /Objects/unicodeobject.c
parent50361d4d9b3e8729aa535c3dfde3d9d2ad899d47 (diff)
downloadcpython-3b718a79af900fdacaf0b825137f69eadc753765.zip
cpython-3b718a79af900fdacaf0b825137f69eadc753765.tar.gz
cpython-3b718a79af900fdacaf0b825137f69eadc753765.tar.bz2
Implemented Martin's suggestion to clear the free lists during the garbage collection of the highest generation.
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r--Objects/unicodeobject.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 74b4796..3e15f53 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -8853,10 +8853,29 @@ void _PyUnicode_Init(void)
/* Finalize the Unicode implementation */
+int
+PyUnicode_ClearFreeList(void)
+{
+ int freelist_size = numfree;
+ PyUnicodeObject *u;
+
+ for (u = free_list; u != NULL;) {
+ PyUnicodeObject *v = u;
+ u = *(PyUnicodeObject **)u;
+ if (v->str)
+ PyMem_DEL(v->str);
+ Py_XDECREF(v->defenc);
+ PyObject_Del(v);
+ numfree--;
+ }
+ free_list = NULL;
+ assert(numfree == 0);
+ return freelist_size;
+}
+
void
_PyUnicode_Fini(void)
{
- PyUnicodeObject *u;
int i;
Py_XDECREF(unicode_empty);
@@ -8868,17 +8887,7 @@ _PyUnicode_Fini(void)
unicode_latin1[i] = NULL;
}
}
-
- for (u = free_list; u != NULL;) {
- PyUnicodeObject *v = u;
- u = *(PyUnicodeObject **)u;
- if (v->str)
- PyMem_DEL(v->str);
- Py_XDECREF(v->defenc);
- PyObject_Del(v);
- }
- free_list = NULL;
- numfree = 0;
+ (void)PyUnicode_ClearFreeList();
}
#ifdef __cplusplus