diff options
Diffstat (limited to 'Objects/bytearrayobject.c')
-rw-r--r-- | Objects/bytearrayobject.c | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index 68b9c4a22f..5b75705abf 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -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; } |