From 4748386b4e22a5bfe0c4d3f0d65c43f37e09536e Mon Sep 17 00:00:00 2001 From: Fabrice Date: Thu, 16 Apr 2026 17:01:13 +0200 Subject: progress on the allocator --- omni/memory.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 omni/memory.h (limited to 'omni/memory.h') diff --git a/omni/memory.h b/omni/memory.h new file mode 100644 index 0000000..def1cc0 --- /dev/null +++ b/omni/memory.h @@ -0,0 +1,25 @@ +#ifndef OMNI_MEMORY_H +#define OMNI_MEMORY_H + +#include "stdint.h" + +struct Layout { + usize size; + usize align; + + template + constexpr static Layout of(usize n) noexcept { + return Layout{n * sizeof(T), alignof(T)}; + } + + static bool from(usize size, usize align) noexcept { + return Layout{size, align}; + } +}; + +struct Allocator { + virtual u8* allocate(Layout layout) noexcept; + virtual void deallocate(u8* ptr); +}; + +#endif -- cgit v1.2.3