libclod
C library for interacting with NBTs, region files, LOD data and other things.
Loading...
Searching...
No Matches
clod_allocator_opts Struct Reference

Configuration options for libclod's memory allocator. More...

#include <memory.h>

Public Attributes

size_t allocator_opts_size
 Size of this struct for future-proofing.
size_t page_size
size_t initial_pages
size_t dedicated_vm_threshold
bool no_grow
void * vm_user
 Passed to the allocator's vm_alloc method.
void *(* vm_alloc )(void *user, size_t size)
void(* vm_free )(void *user, void *ptr, size_t size)

Detailed Description

Configuration options for libclod's memory allocator.

Definition at line 37 of file memory.h.

Member Data Documentation

◆ allocator_opts_size

size_t clod_allocator_opts::allocator_opts_size

Size of this struct for future-proofing.

Definition at line 39 of file memory.h.

◆ page_size

size_t clod_allocator_opts::page_size

Page size. Backing memory is only allocated with multiples of this. Must be a multiple of 2. Defaults to the result of clod_vm_page_size.

Definition at line 44 of file memory.h.

◆ initial_pages

size_t clod_allocator_opts::initial_pages

The initial size of the backing memory in pages. The actual amount of memory that can be allocated will be less than this, and no method for discerning the actual amount of memory that can be allocated exists. This is because fragmentation can and will happen through usage, and it can waste arbitrary amounts of memory. Defaults to the system memory size, or 16GiB if not available.

Definition at line 51 of file memory.h.

◆ dedicated_vm_threshold

size_t clod_allocator_opts::dedicated_vm_threshold

Allocations above this size will be fulfilled with a dedicated call to vm_alloc. Defaults to 64MiB.

Definition at line 55 of file memory.h.

◆ no_grow

bool clod_allocator_opts::no_grow

If true, the allocator will only allocate a single backing memory region of size initial_pages, and allocations which do not fit in the memory region will fail instead of allocating more backing storage. Defaults to false.

Definition at line 61 of file memory.h.

◆ vm_user

void* clod_allocator_opts::vm_user

Passed to the allocator's vm_alloc method.

Definition at line 64 of file memory.h.

◆ vm_alloc

void *(* clod_allocator_opts::vm_alloc) (void *user, size_t size)

Method used to get backing memory for the allocator i.e. virtual-memory mapping function. It is only called with multiples of page_size. Defaults to clod_vm_alloc.

Definition at line 69 of file memory.h.

◆ vm_free

void(* clod_allocator_opts::vm_free) (void *user, void *ptr, size_t size)

Method used to free backing memory for the allocator i.e. virtual-memory unmapping function. Defaults to clod_vm_free.

Definition at line 73 of file memory.h.


The documentation for this struct was generated from the following file: