diff options
Diffstat (limited to 'Kernel/Heap/SlabAllocator.h')
-rw-r--r-- | Kernel/Heap/SlabAllocator.h | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/Kernel/Heap/SlabAllocator.h b/Kernel/Heap/SlabAllocator.h index de826d38e7..bfaa2c99e1 100644 --- a/Kernel/Heap/SlabAllocator.h +++ b/Kernel/Heap/SlabAllocator.h @@ -19,11 +19,23 @@ void slab_dealloc(void*, size_t slab_size); void slab_alloc_init(); void slab_alloc_stats(Function<void(size_t slab_size, size_t allocated, size_t free)>); -#define MAKE_SLAB_ALLOCATED(type) \ -public: \ - [[nodiscard]] void* operator new(size_t) noexcept { return slab_alloc(sizeof(type)); } \ - void operator delete(void* ptr) noexcept { slab_dealloc(ptr, sizeof(type)); } \ - \ +#define MAKE_SLAB_ALLOCATED(type) \ +public: \ + [[nodiscard]] void* operator new(size_t) \ + { \ + void* ptr = slab_alloc(sizeof(type)); \ + VERIFY(ptr); \ + return ptr; \ + } \ + [[nodiscard]] void* operator new(size_t, const std::nothrow_t&) noexcept \ + { \ + return slab_alloc(sizeof(type)); \ + } \ + void operator delete(void* ptr) noexcept \ + { \ + slab_dealloc(ptr, sizeof(type)); \ + } \ + \ private: } |