summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2008-01-27 23:34:59 (GMT)
committerChristian Heimes <christian@cheimes.de>2008-01-27 23:34:59 (GMT)
commit908caac52e8e62baa1ee54e4e650e1cd3ac37907 (patch)
tree291efd46f16d74de6e49bba69f785883c6cdfcc1 /Objects
parent3ea7b41b5805c60a05e697211d0bfc14a62a19fb (diff)
downloadcpython-908caac52e8e62baa1ee54e4e650e1cd3ac37907.zip
cpython-908caac52e8e62baa1ee54e4e650e1cd3ac37907.tar.gz
cpython-908caac52e8e62baa1ee54e4e650e1cd3ac37907.tar.bz2
Added clear cache methods to clear the internal type lookup cache for ref leak test runs.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index ce413e6..073ee31 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -32,6 +32,24 @@ struct method_cache_entry {
static struct method_cache_entry method_cache[1 << MCACHE_SIZE_EXP];
static unsigned int next_version_tag = 0;
+static void type_modified(PyTypeObject *);
+
+unsigned int
+PyType_ClearCache(void)
+{
+ Py_ssize_t i;
+ unsigned int cur_version_tag = next_version_tag - 1;
+
+ for (i = 0; i < (1 << MCACHE_SIZE_EXP); i++) {
+ method_cache[i].version = 0;
+ Py_CLEAR(method_cache[i].name);
+ method_cache[i].value = NULL;
+ }
+ next_version_tag = 0;
+ /* mark all version tags as invalid */
+ type_modified(&PyBaseObject_Type);
+ return cur_version_tag;
+}
static void
type_modified(PyTypeObject *type)