From cb9fa588ba8144fcdd52ba4b83d69d93fb18066f Mon Sep 17 00:00:00 2001 From: Dominick Allen Date: Sun, 30 Mar 2025 23:08:43 -0500 Subject: Add hash map. --- include/fud_allocator.hpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'include/fud_allocator.hpp') diff --git a/include/fud_allocator.hpp b/include/fud_allocator.hpp index 99b33ce..8940dcd 100644 --- a/include/fud_allocator.hpp +++ b/include/fud_allocator.hpp @@ -79,34 +79,30 @@ extern NullAllocator globalNullAllocator; template class SimpleStackAllocator final : public Allocator { private: + size_t m_allocated{0}; // NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays) std::byte m_memory[Size]{}; - size_t m_allocated{0}; public: ~SimpleStackAllocator() final = default; Result allocate(size_t bytes, size_t alignment = alignof(std::max_align_t)) final { - using RetType = Result; static_cast(alignment); - if (bytes > Size - m_allocated) { - return RetType::error(FudStatus::AllocFailure); + if (bytes > (Size - m_allocated)) { + return Error{FudStatus::AllocFailure}; } auto* data = m_memory + m_allocated; m_allocated += bytes; - return RetType::okay(data); + return Okay{data}; } void deallocate(std::byte* pointer, size_t bytes) final { - if (pointer + bytes != m_memory + m_allocated) { - m_allocated = Size; - return; - } - m_allocated -= bytes; + static_cast(pointer); + static_cast(bytes); } [[nodiscard]] bool isEqual(const Allocator& rhs) const final -- cgit v1.2.3