summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-11-29 11:15:21 (GMT)
committerGitHub <noreply@github.com>2022-11-29 11:15:21 (GMT)
commit74d5f61ebd1cb14907bf7dae1ad9c1e676707bc5 (patch)
tree2ff77f8a0571edb5690e9e22209fb76e99a81560 /Modules
parent4246fe977d850f8b78505c982f055d33d52ff339 (diff)
downloadcpython-74d5f61ebd1cb14907bf7dae1ad9c1e676707bc5.zip
cpython-74d5f61ebd1cb14907bf7dae1ad9c1e676707bc5.tar.gz
cpython-74d5f61ebd1cb14907bf7dae1ad9c1e676707bc5.tar.bz2
gh-99845: Clean up _PyObject_VAR_SIZE() usage (#99847)
* code_sizeof() now uses an unsigned type (size_t) to compute the result. * Fix _PyObject_ComputedDictPointer(): cast _PyObject_VAR_SIZE() to Py_ssize_t, rather than long: it's a different type on 64-bit Windows. * Clarify that _PyObject_VAR_SIZE() uses an unsigned type (size_t).
Diffstat (limited to 'Modules')
-rw-r--r--Modules/gcmodule.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
index cacfad7..6630faa 100644
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -2329,7 +2329,6 @@ _PyObject_GC_New(PyTypeObject *tp)
PyVarObject *
_PyObject_GC_NewVar(PyTypeObject *tp, Py_ssize_t nitems)
{
- size_t size;
PyVarObject *op;
if (nitems < 0) {
@@ -2337,7 +2336,7 @@ _PyObject_GC_NewVar(PyTypeObject *tp, Py_ssize_t nitems)
return NULL;
}
size_t presize = _PyType_PreHeaderSize(tp);
- size = _PyObject_VAR_SIZE(tp, nitems);
+ size_t size = _PyObject_VAR_SIZE(tp, nitems);
op = (PyVarObject *)gc_alloc(size, presize);
if (op == NULL) {
return NULL;
@@ -2351,7 +2350,7 @@ _PyObject_GC_Resize(PyVarObject *op, Py_ssize_t nitems)
{
const size_t basicsize = _PyObject_VAR_SIZE(Py_TYPE(op), nitems);
_PyObject_ASSERT((PyObject *)op, !_PyObject_GC_IS_TRACKED(op));
- if (basicsize > PY_SSIZE_T_MAX - sizeof(PyGC_Head)) {
+ if (basicsize > (size_t)PY_SSIZE_T_MAX - sizeof(PyGC_Head)) {
return (PyVarObject *)PyErr_NoMemory();
}