bpo-39573: Add Py_SET_SIZE() function (GH-18400)

Add Py_SET_SIZE() function to set the size of an object.
This commit is contained in:
Victor Stinner 2020-02-07 12:05:12 +01:00 committed by GitHub
parent 877ea88934
commit b10dc3e7a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 2 deletions

View file

@ -133,6 +133,11 @@ static inline void _Py_SET_TYPE(PyObject *ob, PyTypeObject *type) {
}
#define Py_SET_TYPE(ob, type) _Py_SET_TYPE(_PyObject_CAST(ob), type)
static inline void _Py_SET_SIZE(PyVarObject *ob, Py_ssize_t refcnt) {
ob->ob_size = refcnt;
}
#define Py_SET_SIZE(ob, refcnt) _Py_SET_SIZE(_PyVarObject_CAST(ob), refcnt)
/*
Type objects contain a string containing the type name (to help somewhat