libcute 0.1
Loading...
Searching...
No Matches
gpallocator.h
Go to the documentation of this file.
1#pragma once
2
5#include "collection/bitmap.h"
6#include "memory/allocator.h"
7#include <stdbool.h>
8#include <stddef.h>
9
10#define CU_GPA_BUCKET_SIZE 4096
11#define CU_GPA_NUM_SMALL_BUCKETS 16
12#define CU_GPA_CANARY 0x9232a6ff85dff10fULL
15struct cu_GPAllocator_BucketHeader;
16
18struct cu_GPAllocator_ObjectPool {
19 cu_Bitmap used;
20 unsigned char *data;
21 size_t objectSize;
22 size_t slotCount;
23 size_t usedCount;
24};
25
27struct cu_GPAllocator_BucketHeader {
28 struct cu_GPAllocator_BucketHeader *prev;
29 struct cu_GPAllocator_BucketHeader *next;
30 struct cu_GPAllocator_ObjectPool objects;
31 size_t canary;
32};
33
35struct cu_GPAllocator_LargeAlloc {
36 struct cu_GPAllocator_LargeAlloc *prev;
37 struct cu_GPAllocator_LargeAlloc *next;
38 cu_Slice slice;
39};
43typedef struct {
45 struct cu_GPAllocator_BucketHeader *smallBuckets[CU_GPA_NUM_SMALL_BUCKETS];
46 struct cu_GPAllocator_BucketHeader
47 *smallBucketTails[CU_GPA_NUM_SMALL_BUCKETS];
48 struct cu_GPAllocator_LargeAlloc
50 size_t bucketSize;
52
53typedef struct {
54 size_t bucketSize;
55 cu_Allocator_Optional backingAllocator;
57
61
#define CU_GPA_NUM_SMALL_BUCKETS
Definition gpallocator.h:11
cu_Allocator cu_Allocator_GPAllocator(cu_GPAllocator *alloc, cu_GPAllocator_Config config)
Definition gpallocator.c:336
void cu_GPAllocator_destroy(cu_GPAllocator *alloc)
Definition gpallocator.c:376
Definition allocator.h:24
Dynamically allocated bitmap.
Definition bitmap.h:16
Definition gpallocator.h:53
size_t bucketSize
Definition gpallocator.h:54
cu_Allocator_Optional backingAllocator
Definition gpallocator.h:55
Definition gpallocator.h:43
struct cu_GPAllocator_LargeAlloc * largeAllocs
Definition gpallocator.h:48
size_t bucketSize
Definition gpallocator.h:50
cu_Allocator backingAllocator
Definition gpallocator.h:44
Definition nostd.h:27