|
@@ -160,14 +160,12 @@ static inline ImVec2 ImMul(const ImVec2& lhs, const ImVec2& rhs)
|
|
|
|
|
|
// We call C++ constructor on own allocated memory via the placement "new(ptr) Type()" syntax.
|
|
// We call C++ constructor on own allocated memory via the placement "new(ptr) Type()" syntax.
|
|
// Defining a custom placement new() with a dummy parameter allows us to bypass including <new> which on some platforms complains when user has disabled exceptions.
|
|
// Defining a custom placement new() with a dummy parameter allows us to bypass including <new> which on some platforms complains when user has disabled exceptions.
|
|
-struct ImNewAllocDummy {};
|
|
|
|
struct ImNewPlacementDummy {};
|
|
struct ImNewPlacementDummy {};
|
|
inline void* operator new(size_t, ImNewPlacementDummy, void* ptr) { return ptr; }
|
|
inline void* operator new(size_t, ImNewPlacementDummy, void* ptr) { return ptr; }
|
|
inline void operator delete(void*, ImNewPlacementDummy, void*) {} // This is only required so we can use the symetrical new()
|
|
inline void operator delete(void*, ImNewPlacementDummy, void*) {} // This is only required so we can use the symetrical new()
|
|
-inline void operator delete(void* p, ImNewAllocDummy) { ImGui::MemFree(p); }
|
|
|
|
-#define IM_PLACEMENT_NEW(_PTR) new(ImNewPlacementDummy(), _PTR)
|
|
|
|
-#define IM_NEW(_TYPE) new(ImNewPlacementDummy(), ImGui::MemAlloc(sizeof(_TYPE))) _TYPE
|
|
|
|
-#define IM_DELETE(_PTR) delete(ImNewAllocDummy(), _PTR), _PTR = NULL
|
|
|
|
|
|
+#define IM_PLACEMENT_NEW(_PTR) new(ImNewPlacementDummy(), _PTR)
|
|
|
|
+#define IM_NEW(_TYPE) new(ImNewPlacementDummy(), ImGui::MemAlloc(sizeof(_TYPE))) _TYPE
|
|
|
|
+template <typename T> void IM_DELETE(T*& p) { if (p) { p->~T(); ImGui::MemFree(p); p = NULL; } }
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
// Types
|
|
// Types
|