mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-11 18:41:14 +00:00
Use delete[] for array types in MxPtrList::Destroy
This commit is contained in:
parent
b90215603b
commit
c695834d66
@ -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)
|
||||
|
||||
|
||||
@ -5,6 +5,8 @@
|
||||
#include "mxcore.h"
|
||||
#include "mxtypes.h"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
template <class T>
|
||||
class MxList;
|
||||
template <class T>
|
||||
@ -71,7 +73,15 @@ class MxPtrList : public MxList<T*> {
|
||||
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<T>::value) {
|
||||
delete[] p_obj;
|
||||
}
|
||||
else {
|
||||
delete p_obj;
|
||||
}
|
||||
}
|
||||
|
||||
void SetOwnership(MxBool p_ownership)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user