tidb: github.com/pingcap/tidb/util/arena Index | Files

package arena

import "github.com/pingcap/tidb/util/arena"

Index

Package Files

arena.go

Variables

var StdAllocator = &stdAllocator{}

StdAllocator implements Allocator but do not pre-allocate memory.

type Allocator Uses

type Allocator interface {
    // Alloc allocates memory with 0 len and capacity cap.
    Alloc(capacity int) []byte

    // AllocWithLen allocates memory with length and capacity.
    AllocWithLen(length int, capacity int) []byte

    // Reset resets arena offset.
    // Make sure all the allocated memory are not used any more.
    Reset()
}

Allocator pre-allocates memory to reduce memory allocation cost. It is not thread-safe.

type SimpleAllocator Uses

type SimpleAllocator struct {
    // contains filtered or unexported fields
}

SimpleAllocator is a simple implementation of ArenaAllocator.

func NewAllocator Uses

func NewAllocator(capacity int) *SimpleAllocator

NewAllocator creates an Allocator with a specified capacity.

func (*SimpleAllocator) Alloc Uses

func (s *SimpleAllocator) Alloc(capacity int) []byte

Alloc implements Allocator.AllocBytes interface.

func (*SimpleAllocator) AllocWithLen Uses

func (s *SimpleAllocator) AllocWithLen(length int, capacity int) []byte

AllocWithLen implements Allocator.AllocWithLen interface.

func (*SimpleAllocator) Reset Uses

func (s *SimpleAllocator) Reset()

Reset implements Allocator.Reset interface.

Package arena is imported by 46 packages. Updated 2018-02-23. Refresh now. Tools for package owners.