resizeBuffer

common
fun resizeBuffer(newSize: Long): Long

Change the size of the buffer so that it equals newSize by either adding new capacity at the end or truncating the buffer at the end. Newly added capacity may span multiple segments.

As a side-effect this cursor will seek. If the buffer is being enlarged it will move UnsafeCursor.offset to the first byte of newly-added capacity. This is the size of the buffer prior to the resizeBuffer() call. If the buffer is being shrunk it will move UnsafeCursor.offset to the end of the buffer.

Warning: it is the caller’s responsibility to write new data to every byte of the newly-allocated capacity. Failure to do so may cause serious security problems as the data in the returned buffers is not zero filled. Buffers may contain dirty pooled segments that hold very sensitive data from other parts of the current process.

Return

the previous size of the buffer.

fun resizeBuffer(newSize: Long): Long