package mallocator
import "github.com/apache/arrow-go/v18/arrow/memory/mallocator"
Package mallocator defines an allocator implementation for memory.Allocator which defers to libc malloc. It requires usage of CGO.
Index ¶
- type Mallocator
- func NewMallocator() *Mallocator
- func NewMallocatorWithAlignment(alignment int) *Mallocator
- func (alloc *Mallocator) Allocate(size int) []byte
- func (alloc *Mallocator) AllocatedBytes() int64
- func (alloc *Mallocator) AssertSize(t TestingT, sz int)
- func (alloc *Mallocator) Free(b []byte)
- func (alloc *Mallocator) Reallocate(size int, b []byte) []byte
- type TestingT
Types ¶
type Mallocator ¶
type Mallocator struct {
// contains filtered or unexported fields
}
Mallocator is an allocator which defers to libc malloc.
The primary reason to use this is when exporting data across the C Data Interface. CGO requires that pointers to Go memory are not stored in C memory, which is exactly what the C Data Interface would otherwise require. By allocating with Mallocator up front, we can safely export the buffers in Arrow arrays without copying buffers or violating CGO rules.
The build tag 'mallocator' will also make this the default allocator.
func NewMallocator ¶
func NewMallocator() *Mallocator
func NewMallocatorWithAlignment ¶
func NewMallocatorWithAlignment(alignment int) *Mallocator
func (*Mallocator) Allocate ¶
func (alloc *Mallocator) Allocate(size int) []byte
func (*Mallocator) AllocatedBytes ¶
func (alloc *Mallocator) AllocatedBytes() int64
func (*Mallocator) AssertSize ¶
func (alloc *Mallocator) AssertSize(t TestingT, sz int)
func (*Mallocator) Free ¶
func (alloc *Mallocator) Free(b []byte)
func (*Mallocator) Reallocate ¶
func (alloc *Mallocator) Reallocate(size int, b []byte) []byte
type TestingT ¶
type TestingT interface { Errorf(format string, args ...interface{}) Helper() }
Duplicate interface to avoid circular import
Source Files ¶
doc.go mallocator.go mallocator_util.go
- Version
- v18.2.0 (latest)
- Published
- Mar 12, 2025
- Platform
- linux/amd64
- Imports
- 4 packages
- Last checked
- 15 hours ago –
Tools for package owners.