balloc

package
v0.0.0-...-727f157 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrOutOfMemory = errors.New("Not enough space allocating memory")
	ErrInvalidSize = errors.New("The requested size is invalid")
)

Functions

This section is empty.

Types

type BufferAllocator

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

BufferAllocator allocates memory in a preallocated buffer

func NewBufferAllocator

func NewBufferAllocator(bufPtr unsafe.Pointer, bufSize uint64, firstFree uint64, pageSize uint16) (*BufferAllocator, error)

NewBufferAllocator created a new buffer allocator

func (*BufferAllocator) Allocate

func (b *BufferAllocator) Allocate(size uint64, zero bool) (uint64, error)

Allocate a new buffer of specific size

func (*BufferAllocator) Deallocate

func (b *BufferAllocator) Deallocate(offset, size uint64) error

func (*BufferAllocator) GetCapacity

func (b *BufferAllocator) GetCapacity() uint64

func (*BufferAllocator) GetFree

func (b *BufferAllocator) GetFree() uint64

func (*BufferAllocator) GetHeader

func (b *BufferAllocator) GetHeader() *header

func (*BufferAllocator) GetOffset

func (b *BufferAllocator) GetOffset(p unsafe.Pointer) uint64

func (*BufferAllocator) GetPageOffset

func (b *BufferAllocator) GetPageOffset(offset uint64) uint64

func (*BufferAllocator) GetPtr

func (b *BufferAllocator) GetPtr(pos uint64) unsafe.Pointer

func (*BufferAllocator) GetUsed

func (b *BufferAllocator) GetUsed() uint64

func (*BufferAllocator) Lock

func (b *BufferAllocator) Lock()

func (*BufferAllocator) PrintFreeChunks

func (b *BufferAllocator) PrintFreeChunks()

func (*BufferAllocator) SetBuffer

func (b *BufferAllocator) SetBuffer(bufPtr unsafe.Pointer, bufSize uint64, firstFree uint64)

func (*BufferAllocator) SetPageSize

func (b *BufferAllocator) SetPageSize(s uint16)

func (*BufferAllocator) Unlock

func (b *BufferAllocator) Unlock()

func (*BufferAllocator) WLock

func (b *BufferAllocator) WLock()

func (*BufferAllocator) WUnlock

func (b *BufferAllocator) WUnlock()

type MemoryManager

type MemoryManager interface {
	Allocate(size uint64, zero bool) (uint64, error)
	Deallocate(pos, size uint64) error

	GetPtr(pos uint64) unsafe.Pointer
	GetOffset(p unsafe.Pointer) uint64

	GetUsed() uint64
	GetFree() uint64

	Lock()
	Unlock()
}

Jump to

Keyboard shortcuts

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