mallocator

package
v18.9.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0, BSD-3-Clause Imports: 4 Imported by: 9 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 NewMallocatorWithAlignment added in v18.2.0

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

Jump to

Keyboard shortcuts

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