Browse Source

Merge pull request #484 from zrax/delete_fixes

Clean up some incorrect uses of operator delete
Adam Johnson 10 years ago
parent
commit
89893745d3
  1. 2
      Sources/Plasma/CoreLib/hsThread_Win.cpp
  2. 30
      Sources/Plasma/PubUtilLib/plInterp/plController.cpp

2
Sources/Plasma/CoreLib/hsThread_Win.cpp

@ -69,7 +69,7 @@ static unsigned int __stdcall gEntryPointBT(void* param)
unsigned int result = wtp->fThread->Run(); unsigned int result = wtp->fThread->Run();
::ReleaseSemaphore(wtp->fQuitSemaH, 1, nil); // signal that we've quit ::ReleaseSemaphore(wtp->fQuitSemaH, 1, nil); // signal that we've quit
wtp->fThread->OnQuit(); wtp->fThread->OnQuit();
delete param; delete wtp;
return result; return result;
} }

30
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 "plAnimTimeConvert.h"
#include <algorithm> #include <algorithm>
#include <type_traits>
///////////////////////////////////////////// /////////////////////////////////////////////
// Controller interp caching // Controller interp caching
@ -78,7 +80,7 @@ void plControllerCacheInfo::SetATC(plAnimTimeConvert *atc)
plLeafController::~plLeafController() plLeafController::~plLeafController()
{ {
delete[] fKeys; delete[] reinterpret_cast<hsKeyFrame *>(fKeys);
} }
void plLeafController::Interp(float time, float* result, plControllerCacheInfo *cache) const void plLeafController::Interp(float time, float* result, plControllerCacheInfo *cache) const
@ -408,57 +410,81 @@ void plLeafController::GetKeyTimes(hsTArray<float> &keyTimes) const
void plLeafController::AllocKeys(uint32_t numKeys, uint8_t type) void plLeafController::AllocKeys(uint32_t numKeys, uint8_t type)
{ {
delete fKeys; delete[] reinterpret_cast<hsKeyFrame *>(fKeys);
fNumKeys = numKeys; fNumKeys = numKeys;
fType = type; fType = type;
switch (fType) switch (fType)
{ {
case hsKeyFrame::kPoint3KeyFrame: case hsKeyFrame::kPoint3KeyFrame:
static_assert(std::is_trivially_destructible<hsPoint3Key>::value,
"hsPoint3Key MUST be trivially destructible");
fKeys = new hsPoint3Key[fNumKeys]; fKeys = new hsPoint3Key[fNumKeys];
break; break;
case hsKeyFrame::kBezPoint3KeyFrame: case hsKeyFrame::kBezPoint3KeyFrame:
static_assert(std::is_trivially_destructible<hsBezPoint3Key>::value,
"hsBezPoint3Key MUST be trivially destructible");
fKeys = new hsBezPoint3Key[fNumKeys]; fKeys = new hsBezPoint3Key[fNumKeys];
break; break;
case hsKeyFrame::kScalarKeyFrame: case hsKeyFrame::kScalarKeyFrame:
static_assert(std::is_trivially_destructible<hsScalarKey>::value,
"hsScalarKey MUST be trivially destructible");
fKeys = new hsScalarKey[fNumKeys]; fKeys = new hsScalarKey[fNumKeys];
break; break;
case hsKeyFrame::kBezScalarKeyFrame: case hsKeyFrame::kBezScalarKeyFrame:
static_assert(std::is_trivially_destructible<hsBezScalarKey>::value,
"hsBezScalarKey MUST be trivially destructible");
fKeys = new hsBezScalarKey[fNumKeys]; fKeys = new hsBezScalarKey[fNumKeys];
break; break;
case hsKeyFrame::kScaleKeyFrame: case hsKeyFrame::kScaleKeyFrame:
static_assert(std::is_trivially_destructible<hsScaleKey>::value,
"hsScaleKey MUST be trivially destructible");
fKeys = new hsScaleKey[fNumKeys]; fKeys = new hsScaleKey[fNumKeys];
break; break;
case hsKeyFrame::kBezScaleKeyFrame: case hsKeyFrame::kBezScaleKeyFrame:
static_assert(std::is_trivially_destructible<hsBezScaleKey>::value,
"hsBezScaleKey MUST be trivially destructible");
fKeys = new hsBezScaleKey[fNumKeys]; fKeys = new hsBezScaleKey[fNumKeys];
break; break;
case hsKeyFrame::kQuatKeyFrame: case hsKeyFrame::kQuatKeyFrame:
static_assert(std::is_trivially_destructible<hsQuatKey>::value,
"hsQuatKey MUST be trivially destructible");
fKeys = new hsQuatKey[fNumKeys]; fKeys = new hsQuatKey[fNumKeys];
break; break;
case hsKeyFrame::kCompressedQuatKeyFrame32: case hsKeyFrame::kCompressedQuatKeyFrame32:
static_assert(std::is_trivially_destructible<hsCompressedQuatKey32>::value,
"hsCompressedQuatKey32 MUST be trivially destructible");
fKeys = new hsCompressedQuatKey32[fNumKeys]; fKeys = new hsCompressedQuatKey32[fNumKeys];
break; break;
case hsKeyFrame::kCompressedQuatKeyFrame64: case hsKeyFrame::kCompressedQuatKeyFrame64:
static_assert(std::is_trivially_destructible<hsCompressedQuatKey64>::value,
"hsCompressedQuatKey64 MUST be trivially destructible");
fKeys = new hsCompressedQuatKey64[fNumKeys]; fKeys = new hsCompressedQuatKey64[fNumKeys];
break; break;
case hsKeyFrame::k3dsMaxKeyFrame: case hsKeyFrame::k3dsMaxKeyFrame:
static_assert(std::is_trivially_destructible<hsG3DSMaxKeyFrame>::value,
"hsG3DSMaxKeyFrame MUST be trivially destructible");
fKeys = new hsG3DSMaxKeyFrame[fNumKeys]; fKeys = new hsG3DSMaxKeyFrame[fNumKeys];
break; break;
case hsKeyFrame::kMatrix33KeyFrame: case hsKeyFrame::kMatrix33KeyFrame:
static_assert(std::is_trivially_destructible<hsMatrix33Key>::value,
"hsMatrix33Key MUST be trivially destructible");
fKeys = new hsMatrix33Key[fNumKeys]; fKeys = new hsMatrix33Key[fNumKeys];
break; break;
case hsKeyFrame::kMatrix44KeyFrame: case hsKeyFrame::kMatrix44KeyFrame:
static_assert(std::is_trivially_destructible<hsMatrix44Key>::value,
"hsMatrix44Key MUST be trivially destructible");
fKeys = new hsMatrix44Key[fNumKeys]; fKeys = new hsMatrix44Key[fNumKeys];
break; break;

Loading…
Cancel
Save