diff options
| author | mashumafi <mashumafi@gmail.com> | 2023-01-29 23:29:31 -0500 |
|---|---|---|
| committer | mashumafi <mashumafi@gmail.com> | 2023-01-29 23:29:31 -0500 |
| commit | a8be6aa8dd980bcce64b55d042e4558b5a91798f (patch) | |
| tree | a1350e3b1404410e83bf1f790d264f6e74f0f0c7 /include/godot_cpp/core | |
| parent | 0f3a0913f100dcd988b538582431d064f46c4e17 (diff) | |
| download | redot-cpp-a8be6aa8dd980bcce64b55d042e4558b5a91798f.tar.gz | |
Move allocator to after memdelete
Diffstat (limited to 'include/godot_cpp/core')
| -rw-r--r-- | include/godot_cpp/core/memory.hpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/include/godot_cpp/core/memory.hpp b/include/godot_cpp/core/memory.hpp index d17e05e..25f87ec 100644 --- a/include/godot_cpp/core/memory.hpp +++ b/include/godot_cpp/core/memory.hpp @@ -92,20 +92,6 @@ struct Comparator { _ALWAYS_INLINE_ bool operator()(const T &p_a, const T &p_b) const { return (p_a < p_b); } }; -class DefaultAllocator { -public: - _ALWAYS_INLINE_ static void *alloc(size_t p_memory) { return Memory::alloc_static(p_memory); } - _ALWAYS_INLINE_ static void free(void *p_ptr) { Memory::free_static(p_ptr); } -}; - -template <class T> -class DefaultTypedAllocator { -public: - template <class... Args> - _ALWAYS_INLINE_ T *new_allocation(const Args &&...p_args) { return memnew(T(p_args...)); } - _ALWAYS_INLINE_ void delete_allocation(T *p_allocation) { memdelete(p_allocation); } -}; - template <class T> void memdelete(T *p_class, typename std::enable_if<!std::is_base_of_v<godot::Wrapped, T>>::type * = nullptr) { if (!std::is_trivially_destructible<T>::value) { @@ -129,6 +115,20 @@ void memdelete_allocator(T *p_class) { A::free(p_class); } +class DefaultAllocator { +public: + _ALWAYS_INLINE_ static void *alloc(size_t p_memory) { return Memory::alloc_static(p_memory); } + _ALWAYS_INLINE_ static void free(void *p_ptr) { Memory::free_static(p_ptr); } +}; + +template <class T> +class DefaultTypedAllocator { +public: + template <class... Args> + _ALWAYS_INLINE_ T *new_allocation(const Args &&...p_args) { return memnew(T(p_args...)); } + _ALWAYS_INLINE_ void delete_allocation(T *p_allocation) { memdelete(p_allocation); } +}; + #define memnew_arr(m_class, m_count) memnew_arr_template<m_class>(m_count) template <typename T> |
