libclod
C library for interacting with NBTs, region files, LOD data and other things.
Loading...
Searching...
No Matches
memory.c
1#include <clod/memory.h>
2#include <clod/sys/vm.h>
3
4#include "allocator.h"
5
7 if (opts == nullptr) {
8 opts = &(struct clod_allocator_opts){0};
9 } else if (opts->allocator_opts_size < sizeof(*opts)) {
10 return nullptr;
11 }
12
13}
14
15void *clod_alloc(clod_allocator *allocator, const size_t size) {
16 if (size == 0) {
17 return (char*)allocator + allocator->size;
18 }
19
20
21}
22
23void clod_free(clod_allocator *allocator, void *ptr) {
24 if (ptr == nullptr) return;
25 if (ptr == (char*)allocator + allocator->size) return;
26
27
28}
29
31
32}
Memory allocation methods.
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 allocator_opts_size
Size of this struct for future-proofing.
Definition memory.h:39
Allocator.
Definition memory.h:16
uint32_t size
Size of backing memory.
Definition allocator.h:173