2
3
4
5
6
7
8#ifndef GIMBAL_ARENA_ALLOCATOR_H
9#define GIMBAL_ARENA_ALLOCATOR_H
11#include "../containers/gimbal_linked_list.h"
12#include "../meta/instances/gimbal_object.h"
13#include "../meta/ifaces/gimbal_iallocator.h"
14#include "../core/gimbal_result.h"
17
18
19
20#define GBL_ARENA_ALLOCATOR_TYPE (GBL_TYPEID(GblArenaAllocator))
21#define GBL_ARENA_ALLOCATOR(self) (GBL_CAST(GblArenaAllocator, self))
22#define GBL_ARENA_ALLOCATOR_CLASS(klass) (GBL_CLASS_CAST(GblArenaAllocator, klass))
23#define GBL_ARENA_ALLOCATOR_GET_CLASS(self) (GBL_CLASSOF(GblArenaAllocator, self))
26#define GBL_SELF_TYPE GblArenaAllocator
33
34
35
36
37
38
39
52} GblArenaAllocatorPage;
55
56
57
58
59
60
61
62
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
104
105
106
107
108
109
110
111
112
113
114
115
116
118 GblArenaAllocatorPage* pActivePage;
120} GblArenaAllocatorState;
128 GblArenaAllocatorPage* pInitialPage,
148#define GblArenaAllocator_construct(...) GblArenaAllocator_constructDefault_
(__VA_ARGS__)
149#define GblArenaAllocator_alloc(...) GblArenaAllocator_allocDefault_
(__VA_ARGS__)
153#define GblArenaAllocator_constructDefault_(...)
155#define GblArenaAllocator_constructDefault__(self, size, align, initial, ctx, ...)
158#define GblArenaAllocator_allocDefault_(...)
159 GblArenaAllocator_allocDefault__
(__VA_ARGS__, 0
)
160#define GblArenaAllocator_allocDefault__(self, size, align, ...)
#define GblArenaAllocator_construct(...)
#define GblArenaAllocator_alloc(...)
#define GBL_CLASS_CAST(cType, klass)
#define GBL_FORWARD_DECLARE_STRUCT(S)
#define GBL_TYPEID(instanceStruct)
#define GBL_INSTANCE_DERIVE(derivedInstance, baseInstance)
#define GBL_CLASS_DERIVE_EMPTY(...)
#define GBL_CLASSOF(cType, self)
#define GBL_CAST(cType, self)
uint8_t GblBool
Basic boolean type, standardized to sizeof(char)
Arena/zone/region/area-based paged allocator.
size_t pageSize
Default page size for all new pages.
GblContext * pCtx
Custom context associated with allocator.
GblArenaAllocatorPage * pActivePage
Active (unfilled) page at list head.
size_t pageAlign
Alignment of each page, also maximum requestable alignment.
GblLinkedListNode listNode
Linked list node base.
size_t allocCount
Total # of allocations across all pages.
Represents a single arena allocation page.
GblLinkedListNode listNode
Linked list node base.
size_t capacity
Page capacity.
struct GblArenaAllocatorPage * pNext
Next (used) allocator page.
size_t used
Number of bytes filled on page.
GblBool staticAlloc
Whether this page is static or heap allocated.
unsigned char bytes[1]
first byte of data segment
Represents the current state of a GblArenaAllocator.