diff options
author | Mitya Selivanov <automainint@guattari.tech> | 2023-12-29 06:21:33 +0100 |
---|---|---|
committer | Mitya Selivanov <automainint@guattari.tech> | 2023-12-29 06:21:33 +0100 |
commit | 2d6c8fec45b23a8a28668ecf3ef281139ab778a7 (patch) | |
tree | 75d2a8538992129a83c0c2b83688289443d697e5 /source/kit/allocator.h | |
parent | 820b171245f2f14766f3accdb0246a4e2c0d596a (diff) | |
download | saw-2d6c8fec45b23a8a28668ecf3ef281139ab778a7.zip |
refactor dependencies; include dependencies source code
Diffstat (limited to 'source/kit/allocator.h')
-rw-r--r-- | source/kit/allocator.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/source/kit/allocator.h b/source/kit/allocator.h new file mode 100644 index 0000000..9bd6e0c --- /dev/null +++ b/source/kit/allocator.h @@ -0,0 +1,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 |