manual

package
v1.1.0-beta.0...-22c91d0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxArrayLen is a safe maximum length for slices on this architecture.
	MaxArrayLen = 1<<31 - 1
)

Variables

This section is empty.

Functions

func Free

func Free(b []byte)

Free frees the specified slice.

func New

func New(n int) []byte

New allocates a slice of size n. The returned slice is from manually managed memory and MUST be released by calling Free. Failure to do so will result in a memory leak.

Types

type Allocator

type Allocator struct {
	RefCnt *atomic.Int64
}

Allocator is a manual allocator for memory.

func (Allocator) Alloc

func (a Allocator) Alloc(n int) []byte

Alloc allocates a new byte slice with the given size.

func (Allocator) CheckRefCnt

func (a Allocator) CheckRefCnt() error

CheckRefCnt checks whether there is memory leak.

func (Allocator) Free

func (a Allocator) Free(b []byte)

Free frees the byte slice.

Jump to

Keyboard shortcuts

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