kiba-engine
system.c
Go to the documentation of this file.
1 
7 
8 #include <kiba/core/memory.h>
9 
10 b8 system_allocator_create(allocator *alloc, usize size) {
11  UNUSED(size);
12  alloc->state = (void *) 42; // set some initialized state
18 
19  return true;
20 }
21 
22 void system_allocator_destroy(allocator *alloc) { UNUSED(alloc); }
23 
24 void *system_allocator_allocate(allocator *alloc, usize size) {
25  UNUSED(alloc);
26  return memory_allocate(size);
27 }
28 
29 void system_allocator_free(allocator *alloc, void *mem, usize size) {
30  UNUSED(alloc);
31  UNUSED(size);
32  memory_free(mem, size);
33 }
34 
36  UNUSED(alloc);
37  KB_WARN("not implemented");
38 }
void allocator_implementation(allocator *alloc, allocator_impl_destroy_fn destroy, allocator_impl_allocate_fn allocate, allocator_impl_free_fn free, allocator_impl_free_all_fn free_all)
Set allocator implementation.
Definition: allocator.c:149
void * memory_allocate(usize size)
Allocate memory.
Definition: memory.c:72
void memory_free(void *mem, usize size)
Free memory.
Definition: memory.c:77
Lightweight layer between platform and other engine components to enable tracing/monitoring.
#define UNUSED(x)
Mark parameter as unused.
Definition: defines.h:21
#define KB_WARN(...)
Log entry with warn log level.
Definition: log.h:161
Central allocator structure.
Definition: allocator.h:87
void * state
Type specific state of the allocator.
Definition: allocator.h:91
void system_allocator_destroy(allocator *alloc)
Definition: system.c:22
void system_allocator_free_all(allocator *alloc)
Definition: system.c:35
void system_allocator_free(allocator *alloc, void *mem, usize size)
Definition: system.c:29
void * system_allocator_allocate(allocator *alloc, usize size)
Definition: system.c:24
b8 system_allocator_create(allocator *alloc, usize size)
Definition: system.c:10
Function signatures for system allocator implementation.