diff options
| author | Syndamia <kamen@syndamia.com> | 2026-04-28 14:06:44 +0300 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2026-05-12 07:08:56 +0300 |
| commit | 0d249b1d47a7f84cfe5f09ad070d1affd26566da (patch) | |
| tree | f395f67eecb27daea3fc4a9ad8e59bf40f988984 /MemoryManager.h | |
| parent | 5c36b582ad60a569ed996fe188ed92ef6bd7fc5f (diff) | |
| download | foollib-0d249b1d47a7f84cfe5f09ad070d1affd26566da.tar foollib-0d249b1d47a7f84cfe5f09ad070d1affd26566da.tar.gz foollib-0d249b1d47a7f84cfe5f09ad070d1affd26566da.zip | |
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.
Diffstat (limited to 'MemoryManager.h')
| -rw-r--r-- | MemoryManager.h | 16 |
1 files changed, 16 insertions, 0 deletions
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 */ |
