summaryrefslogtreecommitdiffstats
path: root/Modules/arraymodule.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-02-07 22:18:08 (GMT)
committerGitHub <noreply@github.com>2020-02-07 22:18:08 (GMT)
commit60ac6ed5579f6666130fc264d3b748ee9575e3aa (patch)
treec21d06611bea34d88dd5922850223837fa6ae733 /Modules/arraymodule.c
parentde6f38db4859f7b8fe4da4556f06c52675fff24a (diff)
downloadcpython-60ac6ed5579f6666130fc264d3b748ee9575e3aa.zip
cpython-60ac6ed5579f6666130fc264d3b748ee9575e3aa.tar.gz
cpython-60ac6ed5579f6666130fc264d3b748ee9575e3aa.tar.bz2
bpo-39573: Use Py_SET_SIZE() function (GH-18402)
Replace direct acccess to PyVarObject.ob_size with usage of the Py_SET_SIZE() function.
Diffstat (limited to 'Modules/arraymodule.c')
-rw-r--r--Modules/arraymodule.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index 5065d28..eeda714 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -128,14 +128,14 @@ array_resize(arrayobject *self, Py_ssize_t newsize)
if (self->allocated >= newsize &&
Py_SIZE(self) < newsize + 16 &&
self->ob_item != NULL) {
- Py_SIZE(self) = newsize;
+ Py_SET_SIZE(self, newsize);
return 0;
}
if (newsize == 0) {
PyMem_FREE(self->ob_item);
self->ob_item = NULL;
- Py_SIZE(self) = 0;
+ Py_SET_SIZE(self, 0);
self->allocated = 0;
return 0;
}
@@ -165,7 +165,7 @@ array_resize(arrayobject *self, Py_ssize_t newsize)
return -1;
}
self->ob_item = items;
- Py_SIZE(self) = newsize;
+ Py_SET_SIZE(self, newsize);
self->allocated = _new_size;
return 0;
}
@@ -593,7 +593,7 @@ newarrayobject(PyTypeObject *type, Py_ssize_t size, const struct arraydescr *des
op->ob_descr = descr;
op->allocated = size;
op->weakreflist = NULL;
- Py_SIZE(op) = size;
+ Py_SET_SIZE(op, size);
if (size <= 0) {
op->ob_item = NULL;
}
@@ -2696,7 +2696,7 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL;
}
self->ob_item = item;
- Py_SIZE(self) = n / sizeof(Py_UNICODE);
+ Py_SET_SIZE(self, n / sizeof(Py_UNICODE));
memcpy(item, ustr, n);
self->allocated = Py_SIZE(self);
}