libclod
C library for interacting with NBTs, region files, LOD data and other things.
Loading...
Searching...
No Matches
memory.h
Go to the documentation of this file.
1
5#ifndef LIBCLOD_MEMORY_H
6#define LIBCLOD_MEMORY_H
7
8#include <clod/lib.h>
9
16typedef struct {
18 void *self;
19
26 void *(*allocate)(size_t size, void *self);
27
33 void (*free)(void *ptr, void *self);
35
40
44 size_t page_size;
45
52
56
61 bool no_grow;
62
64 void *vm_user;
65
69 void *(*vm_alloc)(void *user, size_t size);
70
73 void (*vm_free)(void *user, void *ptr, size_t size);
74};
75
93CLOD_API
95
101CLOD_API CLOD_NONNULL(1)
103
104#endif
void clod_allocator_destroy(clod_allocator *allocator)
Definition memory.c:30
clod_allocator * clod_allocator_create(const struct clod_allocator_opts *opts)
Definition memory.c:6
Configuration options for libclod's memory allocator.
Definition memory.h:37
size_t initial_pages
Definition memory.h:51
size_t dedicated_vm_threshold
Definition memory.h:55
void * vm_user
Passed to the allocator's vm_alloc method.
Definition memory.h:64
void(* vm_free)(void *user, void *ptr, size_t size)
Definition memory.h:73
size_t allocator_opts_size
Size of this struct for future-proofing.
Definition memory.h:39
Allocator.
Definition memory.h:16
void * self
Value passed to invocations of allocate and free.
Definition memory.h:18
void(* free)(void *ptr, void *self)
Definition memory.h:33
uint32_t size
Size of backing memory.
Definition allocator.h:173