mirror of
https://github.com/python/cpython.git
synced 2025-07-30 14:44:10 +00:00
Issue #21233: Revert bytearray(int) optimization using calloc()
This commit is contained in:
parent
d8f0d922d5
commit
2bc4d95bb6
3 changed files with 7 additions and 21 deletions
|
@ -813,21 +813,9 @@ bytearray_init(PyByteArrayObject *self, PyObject *args, PyObject *kwds)
|
|||
}
|
||||
else {
|
||||
if (count > 0) {
|
||||
void *sval;
|
||||
Py_ssize_t alloc;
|
||||
|
||||
assert (Py_SIZE(self) == 0);
|
||||
|
||||
alloc = count + 1;
|
||||
sval = PyObject_Calloc(1, alloc);
|
||||
if (sval == NULL)
|
||||
if (PyByteArray_Resize((PyObject *)self, count))
|
||||
return -1;
|
||||
|
||||
PyObject_Free(self->ob_bytes);
|
||||
|
||||
self->ob_bytes = self->ob_start = sval;
|
||||
Py_SIZE(self) = count;
|
||||
self->ob_alloc = alloc;
|
||||
memset(PyByteArray_AS_STRING(self), 0, count);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue