From 0d249b1d47a7f84cfe5f09ad070d1affd26566da Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 28 Apr 2026 14:06:44 +0300 Subject: feat!: Refactor using MemoryManager The idea is to provide a universal memory management "API", through which you allocate and deallocate. This allows our implementations (for String and Vector) to be more generic. It does also allow usage of different allocators depending on situation. --- MemoryManager.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 MemoryManager.h (limited to 'MemoryManager.h') diff --git a/MemoryManager.h b/MemoryManager.h new file mode 100644 index 0000000..95f864c --- /dev/null +++ b/MemoryManager.h @@ -0,0 +1,16 @@ +#ifndef _MEMORY_MANAGER +#define _MEMORY_MANAGER + +#include "Types.h" + +typedef struct MemoryManager { + Result (* const alloc)(struct MemoryManager mm, void **ptr, usize size); + Result (* const realloc)(struct MemoryManager mm, void **ptr, usize new_size); + Result (* const free)(struct MemoryManager mm, void **ptr); + Result (* const destroy)(struct MemoryManager *mm); + void *priv; +} MemoryManager; + +MemoryManager M_std(); + +#endif /* _MEMORY_MANAGER */ -- cgit v1.2.3