blob: eda866f48fa86b1cff6e0c3cfa0010b26db8d7ea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# Memory Pool
---
## Object Definitions
```c
#define KPL_SLAB_HEADER(STRUCT) struct STRUCT *prev, *next;
typedef struct _kpl_slab_obj {
KPL_SLAB_HEADER(_kpl_slab_obj);
} kpl_slab_obj;
typedef struct _kpl_slab {
size_t array_index;
struct _kpl_slab *next;
uint8_t array[];
} kpl_slab_alloc;
typedef struct {
uint32_t object_size, array_size;
_Atomic size_t slab_length;
kpl_slab *slab;
kpl_slab_obj *head;
kpl_mutex mutex;
} kpl_slab;
#define KPL_POOL_HEADER(STRUCT) KPL_SLAB_HEADER(STRUCT); uint32_t obj_byte_size
typedef struct _kpl_pool_obj {
KPL_POOL_HEADER(_kpl_pool_obj);
} kpl_pool_obj;
typedef strut {
uint32_t min_obj_size;
_Atomic size_t alloc_byte_size;
kpl_pool_obj *head;
kpl_mutex mutex;
} kpl_pool;
```
## Pool Object Size
The max size of an object in the pool is 2 \*\* 32
This allows for 4 aligned bytes after the `POOL_HEADER` macro
## Slab Leak Detection
On debug builds before each slab is freed, all items removed from the slab should be found on the slabs pool
## List Management
## Tree Management
|