bytealloc

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type A

type A []byte

An A provides chunk allocation of []byte, amortizing the overhead of each allocation. Because the underlying storage for the slices is shared, they should share a similar lifetime in order to avoid pinning large amounts of memory unnecessarily. The allocator itself is a []byte where cap() indicates the total amount of memory and len() is the amount already allocated. The size of the buffer to allocate from is grown exponentially when it runs out of room up to a maximum size (chunkAllocMaxSize).

func (A) Alloc

func (a A) Alloc(n int) (A, []byte)

Alloc allocates a new chunk of memory with the specified length.

func (A) Copy

func (a A) Copy(src []byte) (A, []byte)

Copy allocates a new chunk of memory, initializing it from src.

func (A) Reset

func (a A) Reset() A

Reset returns the current chunk, resetting allocated memory back to none. Future allocations will use memory previously allocated by previous calls to Alloc or Copy, so the caller must know know that none of the previously allocated byte slices are still in use.

Jump to

Keyboard shortcuts

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