package memory
import "git.sr.ht/~sbinet/go-arrow/memory"
Package memory provides support for allocating and manipulating memory at a low level.
Index ¶
- func Set(buf []byte, c byte)
- type Allocator
- type Buffer
- func NewBufferBytes(data []byte) *Buffer
- func NewResizableBuffer(mem Allocator) *Buffer
- func (b *Buffer) Buf() []byte
- func (b *Buffer) Bytes() []byte
- func (b *Buffer) Cap() int
- func (b *Buffer) Len() int
- func (b *Buffer) Mutable() bool
- func (b *Buffer) Release()
- func (b *Buffer) Reserve(capacity int)
- func (b *Buffer) Reset(buf []byte)
- func (b *Buffer) Resize(newSize int)
- func (b *Buffer) ResizeNoShrink(newSize int)
- func (b *Buffer) Retain()
- type CheckedAllocator
- func NewCheckedAllocator(mem Allocator) *CheckedAllocator
- func (a *CheckedAllocator) Allocate(size int) []byte
- func (a *CheckedAllocator) AssertSize(t TestingT, sz int)
- func (a *CheckedAllocator) Free(b []byte)
- func (a *CheckedAllocator) Reallocate(size int, b []byte) []byte
- type CheckedAllocatorScope
- func NewCheckedAllocatorScope(alloc *CheckedAllocator) *CheckedAllocatorScope
- func (c *CheckedAllocatorScope) CheckSize(t TestingT)
- type GoAllocator
- func NewGoAllocator() *GoAllocator
- func (a *GoAllocator) Allocate(size int) []byte
- func (a *GoAllocator) Free(b []byte)
- func (a *GoAllocator) Reallocate(size int, b []byte) []byte
- type TestingT
Functions ¶
func Set ¶
Set assigns the value c to every element of the slice buf.
Types ¶
type Allocator ¶
type Allocator interface { Allocate(size int) []byte Reallocate(size int, b []byte) []byte Free(b []byte) }
var DefaultAllocator Allocator = NewGoAllocator()
DefaultAllocator is a default implementation of Allocator and can be used anywhere an Allocator is required.
DefaultAllocator is safe to use from multiple goroutines.
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is a wrapper type for a buffer of bytes.
func NewBufferBytes ¶
NewBufferBytes creates a fixed-size buffer from the specified data.
func NewResizableBuffer ¶
NewResizableBuffer creates a mutable, resizable buffer with an Allocator for managing memory.
func (*Buffer) Buf ¶
Buf returns the slice of memory allocated by the Buffer, which is adjusted by calling Reserve.
func (*Buffer) Bytes ¶
Bytes returns a slice of size Len, which is adjusted by calling Resize.
func (*Buffer) Cap ¶
Cap returns the capacity of the buffer.
func (*Buffer) Len ¶
Len returns the length of the buffer.
func (*Buffer) Mutable ¶
Mutable returns a bool indicating whether the buffer is mutable or not.
func (*Buffer) Release ¶
func (b *Buffer) Release()
Release decreases the reference count by 1. When the reference count goes to zero, the memory is freed.
func (*Buffer) Reserve ¶
Reserve reserves the provided amount of capacity for the buffer.
func (*Buffer) Reset ¶
Reset resets the buffer for reuse.
func (*Buffer) Resize ¶
Resize resizes the buffer to the target size.
func (*Buffer) ResizeNoShrink ¶
ResizeNoShrink resizes the buffer to the target size, but will not shrink it.
func (*Buffer) Retain ¶
func (b *Buffer) Retain()
Retain increases the reference count by 1.
type CheckedAllocator ¶
type CheckedAllocator struct {
// contains filtered or unexported fields
}
func NewCheckedAllocator ¶
func NewCheckedAllocator(mem Allocator) *CheckedAllocator
func (*CheckedAllocator) Allocate ¶
func (a *CheckedAllocator) Allocate(size int) []byte
func (*CheckedAllocator) AssertSize ¶
func (a *CheckedAllocator) AssertSize(t TestingT, sz int)
func (*CheckedAllocator) Free ¶
func (a *CheckedAllocator) Free(b []byte)
func (*CheckedAllocator) Reallocate ¶
func (a *CheckedAllocator) Reallocate(size int, b []byte) []byte
type CheckedAllocatorScope ¶
type CheckedAllocatorScope struct {
// contains filtered or unexported fields
}
func NewCheckedAllocatorScope ¶
func NewCheckedAllocatorScope(alloc *CheckedAllocator) *CheckedAllocatorScope
func (*CheckedAllocatorScope) CheckSize ¶
func (c *CheckedAllocatorScope) CheckSize(t TestingT)
type GoAllocator ¶
type GoAllocator struct{}
func NewGoAllocator ¶
func NewGoAllocator() *GoAllocator
func (*GoAllocator) Allocate ¶
func (a *GoAllocator) Allocate(size int) []byte
func (*GoAllocator) Free ¶
func (a *GoAllocator) Free(b []byte)
func (*GoAllocator) Reallocate ¶
func (a *GoAllocator) Reallocate(size int, b []byte) []byte
type TestingT ¶
type TestingT interface { Errorf(format string, args ...interface{}) Helper() }
Source Files ¶
allocator.go buffer.go checked_allocator.go doc.go go_allocator.go memory.go memory_amd64.go memory_avx2_amd64.go memory_sse4_amd64.go util.go
- Version
- v0.3.0 (latest)
- Published
- Feb 17, 2025
- Platform
- linux/amd64
- Imports
- 4 packages
- Last checked
- 4 months ago –
Tools for package owners.