bufalloc

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2017 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByteAllocator

type ByteAllocator []byte

ByteAllocator 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 (ByteAllocator) Alloc

func (a ByteAllocator) Alloc(n int, extraCap int) (ByteAllocator, []byte)

Alloc allocates a new chunk of memory with the specified length. extraCap indicates additional zero bytes that will be present in the returned []byte, but not part of the length.

func (ByteAllocator) Copy

func (a ByteAllocator) Copy(src []byte, extraCap int) (ByteAllocator, []byte)

Copy allocates a new chunk of memory, initializing it from src. extraCap indicates additional zero bytes that will be present in the returned []byte, but not part of the length.

Jump to

Keyboard shortcuts

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