mimalloc

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: MIT Imports: 2 Imported by: 0

README

go-mimalloc

A Golang wrapper of the mimalloc general-purpose allocator library.

Requeriments

This library makes use of C code. To compile it, CGO must be enabled by adding CGO_ENABLED=1 environment variable and gcc compiler must be installed and accessible through the system PATH.

Usage

package main

import (
	"github.com/mxmauro/go-mimalloc"
)

func main() {
	ptr := mimalloc.Malloc(1000)
	// Do whatever
	mimalloc.Free(ptr)
}

LICENSES

Underlying mimalloc library: MIT

Wrapper: MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArenaCalloc

func ArenaCalloc(arena unsafe.Pointer, count uintptr, size uintptr) unsafe.Pointer

ArenaCalloc allocates memory like Calloc but in the given arena.

func ArenaCreate

func ArenaCreate() unsafe.Pointer

ArenaCreate creates a new arena. An arena groups a set of memory allocations.

func ArenaDestroy

func ArenaDestroy(arena unsafe.Pointer)

ArenaDestroy destroys the given arena. All allocated memory of this arena will be also freed.

func ArenaFree

func ArenaFree(_ unsafe.Pointer, ptr unsafe.Pointer)

ArenaFree deallocates a block of memory in the given arena.

func ArenaMSize

func ArenaMSize(_ unsafe.Pointer, ptr unsafe.Pointer) uintptr

ArenaMSize returns the size of an allocated block of unmanaged memory.

func ArenaMalloc

func ArenaMalloc(arena unsafe.Pointer, size uintptr) unsafe.Pointer

ArenaMalloc allocates memory like Malloc but in the given arena.

func ArenaRealloc

func ArenaRealloc(arena unsafe.Pointer, ptr unsafe.Pointer, size uintptr) unsafe.Pointer

ArenaRealloc re-allocates memory like Realloc but in the given arena.

func Calloc

func Calloc(count uintptr, size uintptr) unsafe.Pointer

Calloc allocates a contiguous block of unmanaged memory. Total amount in bytes is count multiplied by size.

func Free

func Free(ptr unsafe.Pointer)

Free deallocates a block of memory.

func MSize

func MSize(ptr unsafe.Pointer) uintptr

MSize returns the size of an allocated block of unmanaged memory.

func Malloc

func Malloc(size uintptr) unsafe.Pointer

Malloc allocates unmanaged memory of the given size in bytes.

func Realloc

func Realloc(ptr unsafe.Pointer, size uintptr) unsafe.Pointer

Realloc changes the size of a previously allocated block of memory. Returns the new location on success.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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