core/mem/virtual

mem_virtual

Types

12

Arena

Arena :: struct { kind: Arena_Kind, curr_block: ^Memory_Block, total_used: uint, total_reserved: uint, default_commit_size: uint, minimum_block_size: uint, temp_count: uint, mutex: sync.Mutex, }Source

Arena is a generalized arena allocator that supports 3 different variants.

Growing: A linked list of `Memory_Block`s allocated with virtual memory.
	Static: A single `Memory_Block` allocated with virtual memory.
	Buffer: A single `Memory_Block` created from a user provided []byte.

Arena_Kind

Arena_Kind :: enum uint { Growing = 0, // Chained memory blocks (singly linked list). Static = 1, // Fixed reservation sized. Buffer = 2, // Uses a fixed sized buffer. }Source

import "base:sanitizer"

Constants

5

Procedures

46

arena_destroy

arena_destroy :: proc(arena: ^Arena, loc = #caller_location)Source

Frees all of the memory allocated by the arena and zeros all of the values of an arena. A buffer based arena does not delete the provided []byte bufffer.

new

new :: proc(arena: ^Arena, T: typeid, loc = #caller_location) -> (ptr: ^T, err: Allocator_Error)Source

The new procedure allocates memory for a type T from a virtual.Arena. The second argument is a type, not a value, and the value return is a pointer to a newly allocated value of that type using the specified allocator.

new_aligned

new_aligned :: proc(arena: ^Arena, T: typeid, alignment: uint, loc = #caller_location) -> (ptr: ^T, err: Allocator_Error)Source

The new_aligned procedure allocates memory for a type T from a virtual.Arena with a specified alignment. The second argument is a type, not a value, and the value return is a pointer to a newly allocated value of that type using the specified allocator.

new_clone

new_clone :: proc(arena: ^Arena, data: T, loc = #caller_location) -> (ptr: ^T, err: Allocator_Error)Source

The new_clone procedure allocates memory for a type T from a virtual.Arena. The second argument is a value that is to be copied to the allocated data. The value returned is a pointer to a newly allocated value of that type using the specified allocator.

Procedure Groups

4

Reference search

Find anything

Documentation preferences

Settings

System theme variants

Used only while Theme is set to System.