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

package arena

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


Package Files



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.

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 74 packages. Updated 2019-12-09. Refresh now. Tools for package owners.