diff options
Diffstat (limited to 'core/os/memory.h')
-rw-r--r-- | core/os/memory.h | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/core/os/memory.h b/core/os/memory.h index 42723152e4..46ffb4124b 100644 --- a/core/os/memory.h +++ b/core/os/memory.h @@ -108,36 +108,42 @@ _ALWAYS_INLINE_ bool predelete_handler(void *) { template <class T> void memdelete(T *p_class) { - if (!predelete_handler(p_class)) + if (!predelete_handler(p_class)) { return; // doesn't want to be deleted - if (!__has_trivial_destructor(T)) + } + if (!__has_trivial_destructor(T)) { p_class->~T(); + } Memory::free_static(p_class, false); } template <class T, class A> void memdelete_allocator(T *p_class) { - if (!predelete_handler(p_class)) + if (!predelete_handler(p_class)) { return; // doesn't want to be deleted - if (!__has_trivial_destructor(T)) + } + if (!__has_trivial_destructor(T)) { p_class->~T(); + } A::free(p_class); } #define memdelete_notnull(m_v) \ { \ - if (m_v) \ + if (m_v) { \ memdelete(m_v); \ + } \ } #define memnew_arr(m_class, m_count) memnew_arr_template<m_class>(m_count) template <typename T> T *memnew_arr_template(size_t p_elements, const char *p_descr = "") { - if (p_elements == 0) + if (p_elements == 0) { return nullptr; + } /** overloading operator new[] cannot be done , because it may not return the real allocated address (it may pad the 'element count' before the actual array). Because of that, it must be done by hand. This is the same strategy used by std::vector, and the Vector class, so it should be safe.*/ |