summaryrefslogtreecommitdiff
path: root/include/fud_allocator.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/fud_allocator.hpp')
-rw-r--r--include/fud_allocator.hpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/include/fud_allocator.hpp b/include/fud_allocator.hpp
index d4feccf..e4078ac 100644
--- a/include/fud_allocator.hpp
+++ b/include/fud_allocator.hpp
@@ -30,9 +30,9 @@ class alignas(std::max_align_t) Allocator {
public:
virtual ~Allocator() = default;
- virtual Result<void*, FudStatus> allocate(size_t bytes, size_t alignment = alignof(std::max_align_t)) = 0;
+ virtual Result<std::byte*, FudStatus> allocate(size_t bytes, size_t alignment = alignof(std::max_align_t)) = 0;
- virtual FudStatus deallocate(void* pointer, size_t bytes) = 0;
+ virtual FudStatus deallocate(std::byte* pointer, size_t bytes) = 0;
virtual bool isEqual(const Allocator& rhs) const = 0;
};
@@ -46,20 +46,33 @@ class FudAllocator : public Allocator {
public:
virtual ~FudAllocator() override = default;
- virtual Result<void*, FudStatus> allocate(size_t bytes, size_t alignment = alignof(std::max_align_t)) override;
+ virtual Result<std::byte*, FudStatus> allocate(size_t bytes, size_t alignment = alignof(std::max_align_t)) override;
- virtual FudStatus deallocate(void* pointer, size_t bytes) override;
+ virtual FudStatus deallocate(std::byte* pointer, size_t bytes) override;
virtual bool isEqual(const Allocator& rhs) const override;
};
extern FudAllocator globalFudAllocator;
+class NullAllocator : public Allocator {
+ public:
+ virtual ~NullAllocator() override = default;
+
+ virtual Result<std::byte*, FudStatus> allocate(size_t bytes, size_t alignment = alignof(std::max_align_t)) override;
+
+ virtual FudStatus deallocate(std::byte* pointer, size_t bytes) override;
+
+ virtual bool isEqual(const Allocator& rhs) const override;
+};
+
+extern NullAllocator globalNullAllocator;
+
/** \brief The default allocation function for globalFudAllocator. */
-extern void* fudAlloc(size_t size);
+extern std::byte* fudAlloc(size_t size);
/** \brief The default deallocation function for globalFudAllocator. */
-extern void fudFree(void* ptr);
+extern void fudFree(std::byte* ptr);
} // namespace fud