From c695834d66230967aeb6d0fa64850a0f3f0c7c9d Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sun, 18 May 2025 10:41:50 -0700 Subject: [PATCH] Use delete[] for array types in `MxPtrList::Destroy` --- CMakeLists.txt | 2 +- LEGO1/omni/include/mxlist.h | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b523183..0c113ad1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ include(CheckCXXSourceCompiles) include(CMakeDependentOption) include(CMakePushCheckState) -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/LEGO1/omni/include/mxlist.h b/LEGO1/omni/include/mxlist.h index f6954168..6d46cb2a 100644 --- a/LEGO1/omni/include/mxlist.h +++ b/LEGO1/omni/include/mxlist.h @@ -5,6 +5,8 @@ #include "mxcore.h" #include "mxtypes.h" +#include + template class MxList; template @@ -71,7 +73,15 @@ class MxPtrList : public MxList { public: MxPtrList(MxBool p_ownership) { SetOwnership(p_ownership); } - static void Destroy(T* p_obj) { delete p_obj; } + static void Destroy(T* p_obj) + { + if constexpr (std::is_pointer::value) { + delete[] p_obj; + } + else { + delete p_obj; + } + } void SetOwnership(MxBool p_ownership) {