From 7ae3ba99268636b5f9867d82292989e3f158e6d0 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Sat, 4 Jul 2015 15:26:55 -0700 Subject: [PATCH] Clean up some incorrect uses of operator delete --- Sources/Plasma/CoreLib/hsThread_Win.cpp | 2 +- .../PubUtilLib/plInterp/plController.cpp | 30 +++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Sources/Plasma/CoreLib/hsThread_Win.cpp b/Sources/Plasma/CoreLib/hsThread_Win.cpp index 6c1d8f46..014aa9f9 100644 --- a/Sources/Plasma/CoreLib/hsThread_Win.cpp +++ b/Sources/Plasma/CoreLib/hsThread_Win.cpp @@ -69,7 +69,7 @@ static unsigned int __stdcall gEntryPointBT(void* param) unsigned int result = wtp->fThread->Run(); ::ReleaseSemaphore(wtp->fQuitSemaH, 1, nil); // signal that we've quit wtp->fThread->OnQuit(); - delete param; + delete wtp; return result; } diff --git a/Sources/Plasma/PubUtilLib/plInterp/plController.cpp b/Sources/Plasma/PubUtilLib/plInterp/plController.cpp index 8f9375e6..3e882302 100644 --- a/Sources/Plasma/PubUtilLib/plInterp/plController.cpp +++ b/Sources/Plasma/PubUtilLib/plInterp/plController.cpp @@ -47,6 +47,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plAnimTimeConvert.h" #include +#include + ///////////////////////////////////////////// // Controller interp caching @@ -78,7 +80,7 @@ void plControllerCacheInfo::SetATC(plAnimTimeConvert *atc) plLeafController::~plLeafController() { - delete[] fKeys; + delete[] reinterpret_cast(fKeys); } void plLeafController::Interp(float time, float* result, plControllerCacheInfo *cache) const @@ -408,57 +410,81 @@ void plLeafController::GetKeyTimes(hsTArray &keyTimes) const void plLeafController::AllocKeys(uint32_t numKeys, uint8_t type) { - delete fKeys; + delete[] reinterpret_cast(fKeys); fNumKeys = numKeys; fType = type; switch (fType) { case hsKeyFrame::kPoint3KeyFrame: + static_assert(std::is_trivially_destructible::value, + "hsPoint3Key MUST be trivially destructible"); fKeys = new hsPoint3Key[fNumKeys]; break; case hsKeyFrame::kBezPoint3KeyFrame: + static_assert(std::is_trivially_destructible::value, + "hsBezPoint3Key MUST be trivially destructible"); fKeys = new hsBezPoint3Key[fNumKeys]; break; case hsKeyFrame::kScalarKeyFrame: + static_assert(std::is_trivially_destructible::value, + "hsScalarKey MUST be trivially destructible"); fKeys = new hsScalarKey[fNumKeys]; break; case hsKeyFrame::kBezScalarKeyFrame: + static_assert(std::is_trivially_destructible::value, + "hsBezScalarKey MUST be trivially destructible"); fKeys = new hsBezScalarKey[fNumKeys]; break; case hsKeyFrame::kScaleKeyFrame: + static_assert(std::is_trivially_destructible::value, + "hsScaleKey MUST be trivially destructible"); fKeys = new hsScaleKey[fNumKeys]; break; case hsKeyFrame::kBezScaleKeyFrame: + static_assert(std::is_trivially_destructible::value, + "hsBezScaleKey MUST be trivially destructible"); fKeys = new hsBezScaleKey[fNumKeys]; break; case hsKeyFrame::kQuatKeyFrame: + static_assert(std::is_trivially_destructible::value, + "hsQuatKey MUST be trivially destructible"); fKeys = new hsQuatKey[fNumKeys]; break; case hsKeyFrame::kCompressedQuatKeyFrame32: + static_assert(std::is_trivially_destructible::value, + "hsCompressedQuatKey32 MUST be trivially destructible"); fKeys = new hsCompressedQuatKey32[fNumKeys]; break; case hsKeyFrame::kCompressedQuatKeyFrame64: + static_assert(std::is_trivially_destructible::value, + "hsCompressedQuatKey64 MUST be trivially destructible"); fKeys = new hsCompressedQuatKey64[fNumKeys]; break; case hsKeyFrame::k3dsMaxKeyFrame: + static_assert(std::is_trivially_destructible::value, + "hsG3DSMaxKeyFrame MUST be trivially destructible"); fKeys = new hsG3DSMaxKeyFrame[fNumKeys]; break; case hsKeyFrame::kMatrix33KeyFrame: + static_assert(std::is_trivially_destructible::value, + "hsMatrix33Key MUST be trivially destructible"); fKeys = new hsMatrix33Key[fNumKeys]; break; case hsKeyFrame::kMatrix44KeyFrame: + static_assert(std::is_trivially_destructible::value, + "hsMatrix44Key MUST be trivially destructible"); fKeys = new hsMatrix44Key[fNumKeys]; break;