Lines Matching refs:size
103 The caller should ensure that the 'size' argument is non-negative and
106 unshare_buffer(bytesio *self, size_t size)
111 assert(size >= (size_t)self->string_size);
112 new_buf = PyBytes_FromStringAndSize(NULL, size);
121 /* Internal routine for changing the size of the buffer of BytesIO objects.
122 The caller should ensure that the 'size' argument is non-negative. Returns
125 resize_buffer(bytesio *self, size_t size)
135 if (size > PY_SSIZE_T_MAX)
138 if (size < alloc / 2) {
139 /* Major downsize; resize down to exact size. */
140 alloc = size + 1;
142 else if (size < alloc) {
143 /* Within allocated size; quick exit */
146 else if (size <= alloc * 1.125) {
148 alloc = size + (size >> 3) + (size < 9 ? 3 : 6);
151 /* Major upsize; resize up to exact size */
152 alloc = size + 1;
171 "new buffer size too large");
394 read_bytes(bytesio *self, Py_ssize_t size)
399 assert(size <= self->string_size);
400 if (size > 1 &&
401 self->pos == 0 && size == PyBytes_GET_SIZE(self->buf) &&
403 self->pos += size;
409 self->pos += size;
410 return PyBytes_FromStringAndSize(output, size);
415 size: Py_ssize_t(accept={int, NoneType}) = -1
418 Read at most size bytes, returned as a bytes object.
420 If the size argument is negative, read until EOF is reached.
425 _io_BytesIO_read_impl(bytesio *self, Py_ssize_t size)
434 if (size < 0 || size > n) {
435 size = n;
436 if (size < 0)
437 size = 0;
440 return read_bytes(self, size);
446 size: Py_ssize_t(accept={int, NoneType}) = -1
449 Read at most size bytes, returned as a bytes object.
451 If the size argument is negative or omitted, read until EOF is reached.
456 _io_BytesIO_read1_impl(bytesio *self, Py_ssize_t size)
459 return _io_BytesIO_read_impl(self, size);
464 size: Py_ssize_t(accept={int, NoneType}) = -1
469 Retain newline. A non-negative size argument limits the maximum
475 _io_BytesIO_readline_impl(bytesio *self, Py_ssize_t size)
482 n = scan_eol(self, size);
489 size as arg: object = None
495 The optional size argument, if given, is an approximate bound on the
503 Py_ssize_t maxsize, size, n;
515 /* No size limit, by default. */
524 size = 0;
540 size += n;
541 if (maxsize > 0 && size >= maxsize)
590 size: Py_ssize_t(accept={int, NoneType}, c_default="self->pos") = None
593 Truncate the file to at most size bytes.
596 The current file position is unchanged. Returns the new size.
600 _io_BytesIO_truncate_impl(bytesio *self, Py_ssize_t size)
606 if (size < 0) {
608 "negative size value %zd", size);
612 if (size < self->string_size) {
613 self->string_size = size;
614 if (resize_buffer(self, size) < 0)
618 return PyLong_FromSsize_t(size);