Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
nit
  • Loading branch information
corona10 committed Mar 9, 2024
commit d429298533996118253df5645352b75ea1d006c9
12 changes: 6 additions & 6 deletions Objects/listobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ free_list_items(PyObject** items, bool use_qsbr)
static int
list_resize(PyListObject *self, Py_ssize_t newsize)
{
size_t new_allocated, num_allocated_bytes;
size_t new_allocated, target_bytes;
Py_ssize_t allocated = self->allocated;

/* Bypass realloc() when a previous overallocation is large enough
Expand Down Expand Up @@ -139,12 +139,12 @@ list_resize(PyListObject *self, Py_ssize_t newsize)
PyObject **old_items = self->ob_item;
if (self->ob_item) {
if (new_allocated < (size_t)allocated) {
num_allocated_bytes = new_allocated * sizeof(PyObject*);
target_bytes = new_allocated * sizeof(PyObject*);
}
else {
num_allocated_bytes = allocated * sizeof(PyObject*);
target_bytes = allocated * sizeof(PyObject*);
}
memcpy(&array->ob_item, self->ob_item, num_allocated_bytes);
memcpy(&array->ob_item, self->ob_item, target_bytes);
}
_Py_atomic_store_ptr_release(&self->ob_item, &array->ob_item);
Comment thread
corona10 marked this conversation as resolved.
self->allocated = new_allocated;
Expand All @@ -155,8 +155,8 @@ list_resize(PyListObject *self, Py_ssize_t newsize)
#else
PyObject **items;
if (new_allocated <= (size_t)PY_SSIZE_T_MAX / sizeof(PyObject *)) {
num_allocated_bytes = new_allocated * sizeof(PyObject *);
items = (PyObject **)PyMem_Realloc(self->ob_item, num_allocated_bytes);
target_bytes = new_allocated * sizeof(PyObject *);
items = (PyObject **)PyMem_Realloc(self->ob_item, target_bytes);
}
else {
// integer overflow
Expand Down