diff --git a/BAN/include/BAN/Memory.h b/BAN/include/BAN/Memory.h index 367dcf9b81..9643cd1645 100644 --- a/BAN/include/BAN/Memory.h +++ b/BAN/include/BAN/Memory.h @@ -15,4 +15,32 @@ namespace BAN static constexpr auto& allocator = malloc; static constexpr auto& deallocator = free; #endif -} \ No newline at end of file + + template + class OwnPtr + { + public: + template + OwnPtr(const Args&... args) + { + m_pointer = new T(args...); + } + + ~OwnPtr() + { + delete m_pointer; + } + + private: + T* m_pointer = nullptr; + }; + +} + +inline void* operator new(size_t size) { return BAN::allocator(size); } +inline void* operator new[](size_t size) { return BAN::allocator(size); } + +inline void operator delete(void* addr) { BAN::deallocator(addr); } +inline void operator delete[](void* addr) { BAN::deallocator(addr); } +inline void operator delete(void* addr, size_t) { BAN::deallocator(addr); } +inline void operator delete[](void* addr, size_t) { BAN::deallocator(addr); } \ No newline at end of file diff --git a/kernel/include/kernel/kmalloc.h b/kernel/include/kernel/kmalloc.h index fdadebfaa6..9e678918d4 100644 --- a/kernel/include/kernel/kmalloc.h +++ b/kernel/include/kernel/kmalloc.h @@ -8,12 +8,3 @@ void kmalloc_dump_nodes(); void* kmalloc_eternal(size_t); void* kmalloc(size_t); void kfree(void*); - - -inline void* operator new(size_t size) { return kmalloc(size); } -inline void* operator new[](size_t size) { return kmalloc(size); } - -inline void operator delete(void* addr) { kfree(addr); } -inline void operator delete[](void* addr) { kfree(addr); } -inline void operator delete(void* addr, size_t) { kfree(addr); } -inline void operator delete[](void* addr, size_t) { kfree(addr); } \ No newline at end of file