Lines Matching defs:size

108 PyByteArray_FromStringAndSize(const char *bytes, Py_ssize_t size)
113 if (size < 0) {
115 "Negative size passed to PyByteArray_FromStringAndSize");
119 /* Prevent buffer overflow when setting alloc to size+1. */
120 if (size == PY_SSIZE_T_MAX) {
128 if (size == 0) {
133 alloc = size + 1;
139 if (bytes != NULL && size > 0)
140 memcpy(new->ob_bytes, bytes, size);
141 new->ob_bytes[size] = '\0'; /* Trailing null byte */
143 Py_SET_SIZE(new, size);
178 size_t size = (size_t) requested_size;
192 if (size + logical_offset + 1 <= alloc) {
193 /* Current buffer is large enough to host the requested size,
195 if (size < alloc / 2) {
196 /* Major downsize; resize down to exact size */
197 alloc = size + 1;
201 Py_SET_SIZE(self, size);
202 PyByteArray_AS_STRING(self)[size] = '\0'; /* Trailing null */
208 if (size <= alloc * 1.125) {
210 alloc = size + (size >> 3) + (size < 9 ? 3 : 6);
213 /* Major upsize; resize up to exact size */
214 alloc = size + 1;
241 Py_SET_SIZE(self, size);
243 obj->ob_bytes[size] = '\0'; /* Trailing null byte */
296 Py_ssize_t size;
305 size = Py_SIZE(self);
306 if (size > PY_SSIZE_T_MAX - vo.len) {
310 if (PyByteArray_Resize((PyObject *)self, size + vo.len) < 0) {
314 memcpy(PyByteArray_AS_STRING(self) + size, vo.buf, vo.len);
328 Py_ssize_t size = mysize * count;
329 PyByteArrayObject* result = (PyByteArrayObject *)PyByteArray_FromStringAndSize(NULL, size);
331 if (result != NULL && size != 0) {
332 _PyBytes_Repeat(result->ob_bytes, size, buf, mysize);
350 const Py_ssize_t size = mysize * count;
351 if (PyByteArray_Resize((PyObject *)self, size) < 0)
355 _PyBytes_Repeat(buf, size, buf, mysize);
568 // GH-91153: We need to do this *before* the size check, in case value has a
569 // nasty __index__ method that changes the size of the bytearray:
608 // GH-91153: We need to do this *before* the size check, in case values
609 // has a nasty __index__ method that changes the size of the bytearray:
730 "attempt to assign bytes of size %zd "
731 "to extended slice of size %zd",
831 Py_ssize_t size;
835 size = view.len;
836 if (PyByteArray_Resize((PyObject *)self, size) < 0) goto fail;
838 &view, size, 'C') < 0)
848 Py_ssize_t size = PySequence_Fast_GET_SIZE(arg);
849 if (PyByteArray_Resize((PyObject *)self, size) < 0) {
854 for (Py_ssize_t i = 0; i < size; i++) {
1356 /* Fix the size of the resulting bytearray */
1770 /* Resize down to exact size. */
2149 Returns the size of the bytearray object in memory, in bytes.
2278 bytearray(int) -> bytes array of size given by the parameter initialized with null bytes\n\