mallocator

package
v18.0.0-...-f9949aa Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0, BSD-3-Clause Imports: 3 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 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 (*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