mallocator

package
v14.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 7 more Imports: 4 Imported by: 0

Documentation

Overview

Package mallocator defines an allocator implementation for memory.Allocator which defers to libc malloc. It requires usage of CGO.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mallocator

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

Mallocator is an allocator which defers to libc malloc.

The priamry 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 (*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

Jump to

Keyboard shortcuts

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