summaryrefslogtreecommitdiffstats
path: root/Objects/listobject.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 /Objects/listobject.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 'Objects/listobject.c')
-rw-r--r--Objects/listobject.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index d83e3cf..a406e70 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -45,7 +45,7 @@ list_resize(PyListObject *self, Py_ssize_t newsize)
*/
if (allocated >= newsize && newsize >= (allocated >> 1)) {
assert(self->ob_item != NULL || newsize == 0);
- Py_SIZE(self) = newsize;
+ Py_SET_SIZE(self, newsize);
return 0;
}
@@ -73,7 +73,7 @@ list_resize(PyListObject *self, Py_ssize_t newsize)
return -1;
}
self->ob_item = items;
- Py_SIZE(self) = newsize;
+ Py_SET_SIZE(self, newsize);
self->allocated = new_allocated;
return 0;
}
@@ -156,7 +156,7 @@ PyList_New(Py_ssize_t size)
return PyErr_NoMemory();
}
}
- Py_SIZE(op) = size;
+ Py_SET_SIZE(op, size);
op->allocated = size;
_PyObject_GC_TRACK(op);
return (PyObject *) op;
@@ -457,7 +457,7 @@ list_slice(PyListObject *a, Py_ssize_t ilow, Py_ssize_t ihigh)
Py_INCREF(v);
dest[i] = v;
}
- Py_SIZE(np) = len;
+ Py_SET_SIZE(np, len);
return (PyObject *)np;
}
@@ -518,7 +518,7 @@ list_concat(PyListObject *a, PyObject *bb)
Py_INCREF(v);
dest[i] = v;
}
- Py_SIZE(np) = size;
+ Py_SET_SIZE(np, size);
return (PyObject *)np;
#undef b
}
@@ -561,7 +561,7 @@ list_repeat(PyListObject *a, Py_ssize_t n)
}
}
}
- Py_SIZE(np) = size;
+ Py_SET_SIZE(np, size);
return (PyObject *) np;
}
@@ -574,7 +574,7 @@ _list_clear(PyListObject *a)
/* Because XDECREF can recursively invoke operations on
this list, we make it empty first. */
i = Py_SIZE(a);
- Py_SIZE(a) = 0;
+ Py_SET_SIZE(a, 0);
a->ob_item = NULL;
a->allocated = 0;
while (--i >= 0) {
@@ -913,7 +913,7 @@ list_extend(PyListObject *self, PyObject *iterable)
if (list_resize(self, mn) < 0)
goto error;
/* Make the list sane again. */
- Py_SIZE(self) = m;
+ Py_SET_SIZE(self, m);
}
/* Run iterator to exhaustion. */
@@ -931,7 +931,7 @@ list_extend(PyListObject *self, PyObject *iterable)
if (Py_SIZE(self) < self->allocated) {
/* steals ref */
PyList_SET_ITEM(self, Py_SIZE(self), item);
- ++Py_SIZE(self);
+ Py_SET_SIZE(self, Py_SIZE(self) + 1);
}
else {
int status = app1(self, item);
@@ -2204,7 +2204,7 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, int reverse)
saved_ob_size = Py_SIZE(self);
saved_ob_item = self->ob_item;
saved_allocated = self->allocated;
- Py_SIZE(self) = 0;
+ Py_SET_SIZE(self, 0);
self->ob_item = NULL;
self->allocated = -1; /* any operation will reset it to >= 0 */
@@ -2421,7 +2421,7 @@ fail:
keyfunc_fail:
final_ob_item = self->ob_item;
i = Py_SIZE(self);
- Py_SIZE(self) = saved_ob_size;
+ Py_SET_SIZE(self, saved_ob_size);
self->ob_item = saved_ob_item;
self->allocated = saved_allocated;
if (final_ob_item != NULL) {
@@ -2811,7 +2811,7 @@ list_subscript(PyListObject* self, PyObject* item)
Py_INCREF(it);
dest[i] = it;
}
- Py_SIZE(result) = slicelength;
+ Py_SET_SIZE(result, slicelength);
return result;
}
}
@@ -2904,7 +2904,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
sizeof(PyObject *));
}
- Py_SIZE(self) -= slicelength;
+ Py_SET_SIZE(self, Py_SIZE(self) - slicelength);
res = list_resize(self, Py_SIZE(self));
for (i = 0; i < slicelength; i++) {