summaryrefslogtreecommitdiffstats
path: root/Objects/codeobject.c
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2022-01-27 19:32:12 (GMT)
committerGitHub <noreply@github.com>2022-01-27 19:32:12 (GMT)
commit26b0482393a313e3bda364a35e7417e9db52c1c4 (patch)
tree6b82196461a27af8d54c68e1573f4c0788f8c38a /Objects/codeobject.c
parent247480a21cb165efdacc346a2d589dfc27e18283 (diff)
downloadcpython-26b0482393a313e3bda364a35e7417e9db52c1c4.zip
cpython-26b0482393a313e3bda364a35e7417e9db52c1c4.tar.gz
cpython-26b0482393a313e3bda364a35e7417e9db52c1c4.tar.bz2
bpo-46476: Simplify and fix _PyStaticCode_Dealloc (GH-30965)
Diffstat (limited to 'Objects/codeobject.c')
-rw-r--r--Objects/codeobject.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index f983d66..bb8ffa7 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -1908,16 +1908,19 @@ _PyCode_ConstantKey(PyObject *op)
}
void
-_PyStaticCode_Dealloc(PyCodeObject *co, _Py_CODEUNIT *firstinstr)
+_PyStaticCode_Dealloc(PyCodeObject *co)
{
- PyMem_Free(co->co_quickened);
- co->co_quickened = NULL;
+ if (co->co_quickened) {
+ PyMem_Free(co->co_quickened);
+ co->co_quickened = NULL;
+ _Py_QuickenedCount--;
+ }
+ co->co_warmup = QUICKENING_INITIAL_WARMUP_VALUE;
PyMem_Free(co->co_extra);
co->co_extra = NULL;
- co->co_firstinstr = firstinstr;
+ co->co_firstinstr = (_Py_CODEUNIT *)PyBytes_AS_STRING(co->co_code);
if (co->co_weakreflist != NULL) {
PyObject_ClearWeakRefs((PyObject *)co);
co->co_weakreflist = NULL;
}
- co->co_warmup = QUICKENING_INITIAL_WARMUP_VALUE;
}