From 60ac6ed5579f6666130fc264d3b748ee9575e3aa Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 7 Feb 2020 23:18:08 +0100 Subject: bpo-39573: Use Py_SET_SIZE() function (GH-18402) Replace direct acccess to PyVarObject.ob_size with usage of the Py_SET_SIZE() function. --- Objects/bytearrayobject.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Objects/bytearrayobject.c') diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index a019b4905a..b2808c05b4 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -148,7 +148,7 @@ PyByteArray_FromStringAndSize(const char *bytes, Py_ssize_t size) memcpy(new->ob_bytes, bytes, size); new->ob_bytes[size] = '\0'; /* Trailing null byte */ } - Py_SIZE(new) = size; + Py_SET_SIZE(new, size); new->ob_alloc = alloc; new->ob_start = new->ob_bytes; new->ob_exports = 0; @@ -206,7 +206,7 @@ PyByteArray_Resize(PyObject *self, Py_ssize_t requested_size) } else { /* Minor downsize; quick exit */ - Py_SIZE(self) = size; + Py_SET_SIZE(self, size); PyByteArray_AS_STRING(self)[size] = '\0'; /* Trailing null */ return 0; } @@ -246,7 +246,7 @@ PyByteArray_Resize(PyObject *self, Py_ssize_t requested_size) } obj->ob_bytes = obj->ob_start = sval; - Py_SIZE(self) = size; + Py_SET_SIZE(self, size); obj->ob_alloc = alloc; obj->ob_bytes[size] = '\0'; /* Trailing null byte */ @@ -498,7 +498,7 @@ bytearray_setslice_linear(PyByteArrayObject *self, } /* memmove() removed bytes, the bytearray object cannot be restored in its previous state. */ - Py_SIZE(self) += growth; + Py_SET_SIZE(self, Py_SIZE(self) + growth); res = -1; } buf = PyByteArray_AS_STRING(self); @@ -886,7 +886,7 @@ bytearray_init(PyByteArrayObject *self, PyObject *args, PyObject *kwds) /* Append the byte */ if (Py_SIZE(self) + 1 < self->ob_alloc) { - Py_SIZE(self)++; + Py_SET_SIZE(self, Py_SIZE(self) + 1); PyByteArray_AS_STRING(self)[Py_SIZE(self)] = '\0'; } else if (PyByteArray_Resize((PyObject *)self, Py_SIZE(self)+1) < 0) -- cgit v1.2.1