From 30740ca4131d1f574718262451b4410207dc8d4e Mon Sep 17 00:00:00 2001 From: Mitya Selivanov Date: Sun, 14 Jul 2024 21:12:37 +0200 Subject: Reworking the build system --- kit/allocator.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 kit/allocator.h (limited to 'kit/allocator.h') diff --git a/kit/allocator.h b/kit/allocator.h new file mode 100644 index 0000000..97e453e --- /dev/null +++ b/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 -- cgit v1.2.3