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

Allocator. More...

#include <memory.h>

Public Attributes

void * self
 Value passed to invocations of allocate and free.
void *(* allocate )(size_t size, void *self)
void(* free )(void *ptr, void *self)
uint32_t checksum
 Checksum.
uint32_t size
 Size of backing memory.
clod_allocatornext
block_ptr last_slab_branch [13]
struct node free
struct node used

Detailed Description

Allocator.

Memory allocator methods. Libclod provides a way to create an allocator built using system virtual memory. Methods that take an allocator for internal usage do not assume the implementation is libclod's. As such, custom allocations methods can be provided everywhere clod_allocator is used unless stated otherwise.

Definition at line 16 of file memory.h.

Member Data Documentation

◆ self

void* clod_allocator::self

Value passed to invocations of allocate and free.

Definition at line 18 of file memory.h.

◆ allocate

void *(* clod_allocator::allocate) (size_t size, void *self)

Allocate memory.

Parameters
[in]selfImplementation defined value.
[in]sizeSize in bytes of the memory to allocate.
Returns
Pointer to the newly allocated memory.

Definition at line 26 of file memory.h.

◆ free [1/2]

void(* clod_allocator::free) (void *ptr, void *self)

Free memory.

Parameters
[in]ptrPointer previously returned from allocate to free.
[in]selfImplementation defined value.

Definition at line 33 of file memory.h.

◆ checksum

uint32_t clod_allocator::checksum

Checksum.

Definition at line 170 of file allocator.h.

◆ size

uint32_t clod_allocator::size

Size of backing memory.

Definition at line 173 of file allocator.h.

◆ next

clod_allocator* clod_allocator::next

The allocator may need to create more than one backing memory instance. This forms a circular linked list between all of them.

Definition at line 177 of file allocator.h.

◆ last_slab_branch

block_ptr clod_allocator::last_slab_branch[13]

Pointer to the tree branch containing the slab that was most recently used to fulfill an allocation. Allows repeated slab-sized allocations to (usually) quickly find a slab with free space instead of searching the used tree.

They should not blindly be used, as the tree may have been restructured. So the usual checks as done when searching the used tree for slabs should still be performed.

Definition at line 186 of file allocator.h.

◆ free [2/2]

struct node clod_allocator::free

Definition at line 188 of file allocator.h.

◆ used

struct node clod_allocator::used

Definition at line 189 of file allocator.h.


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