buffer

package
v0.0.0-...-32c7374 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer interface {
	buffer.Buffer
	buffer.Writer

	// Rem returns the remaining capacity of the buffer.
	Rem() int

	// Free releases the buffer and its internal resources.
	// The buffer cannot be used after it has been freed.
	Free()
}

Buffer is a byte buffer, which internally allocates memory in blocks.

func Acquire

func Acquire() Buffer

Acquire returns a new buffer from the pool.

The buffer must not be used or even referenced after Free. Use these method only when buffers do not escape an isolated scope.

Typical usage:

buf := alloc.AcquireBuffer()
defer buf.Free() // free immediately

func New

func New() Buffer

New returns a new buffer.

func NewSize

func NewSize(size int) Buffer

NewSize returns a new buffer with a preallocated memory storage.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL