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
|
#ifndef KIT_ALLOCATOR_H
#define KIT_ALLOCATOR_H
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif
enum {
KIT_ALLOC_TYPE_NONE,
KIT_ALLOC_TYPE_DEFAULT,
KIT_ALLOC_TYPE_BUFFER,
};
enum {
KIT_ALLOCATE,
KIT_ALLOCATE_ZERO,
KIT_DEALLOCATE,
KIT_REALLOCATE,
KIT_REALLOCATE_ZERO,
KIT_DEALLOCATE_ALL,
};
typedef struct {
i32 type;
i64 size;
union {
u8 *bytes;
void *data;
};
} kit_allocator_t;
// Application should implement this function if custom allocator
// dispatch is enabled.
//
// See KIT_ENABLE_CUSTOM_ALLOC_DISPATCH macro.
//
void *kit_alloc_dispatch(kit_allocator_t *alloc, i32 request,
i64 size, i64 previous_size, void *pointer);
kit_allocator_t kit_alloc_default(void);
kit_allocator_t kit_alloc_buffer(i64 size, void *buffer);
#ifdef __cplusplus
}
#endif
#endif
|