From abbbfc12d725b86cb137f7f5a2df4d33571965e7 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Fri, 4 Jan 2013 00:00:14 -0800 Subject: [PATCH] Plug some simple leaks detected during startup --- .../pfSecurePreloader/pfSecurePreloader.cpp | 14 +++++--------- .../pfSecurePreloader/pfSecurePreloader.h | 2 +- .../NucleusLib/pnNetProtocol/Private/pnNpCommon.h | 4 ++-- .../PubUtilLib/plNetClient/plNetLinkingMgr.cpp | 7 +++++++ .../PubUtilLib/plNetClient/plNetLinkingMgr.h | 3 ++- .../PubUtilLib/plNetGameLib/Private/plNglAuth.cpp | 7 +++++++ .../Plasma/PubUtilLib/plPipeline/plBinkPlayer.h | 1 + 7 files changed, 25 insertions(+), 13 deletions(-) diff --git a/Sources/Plasma/FeatureLib/pfSecurePreloader/pfSecurePreloader.cpp b/Sources/Plasma/FeatureLib/pfSecurePreloader/pfSecurePreloader.cpp index 33f0405a..c9e1469b 100644 --- a/Sources/Plasma/FeatureLib/pfSecurePreloader/pfSecurePreloader.cpp +++ b/Sources/Plasma/FeatureLib/pfSecurePreloader/pfSecurePreloader.cpp @@ -269,10 +269,13 @@ void pfSecurePreloader::PreloadNextFile() void pfSecurePreloader::Init() { - RegisterAs(kSecurePreloader_KEY); + if (!fInstance) + fInstance = new pfSecurePreloader; + + fInstance->RegisterAs(kSecurePreloader_KEY); // TODO: If we're going to support reconnects, then let's do it right. // Later... - //plgDispatch::Dispatch()->RegisterForExactType(plNetCommAuthConnectedMsg::Index(), GetKey()); + //plgDispatch::Dispatch()->RegisterForExactType(plNetCommAuthConnectedMsg::Index(), fInstance->GetKey()); } void pfSecurePreloader::Start() @@ -431,10 +434,3 @@ void pfSecurePreloader::FilePreloaded(const wchar_t* file, hsStream* stream) // Continue down the warpath PreloadNextFile(); } - -pfSecurePreloader* pfSecurePreloader::GetInstance() -{ - if (!fInstance) - fInstance = new pfSecurePreloader; - return fInstance; -} diff --git a/Sources/Plasma/FeatureLib/pfSecurePreloader/pfSecurePreloader.h b/Sources/Plasma/FeatureLib/pfSecurePreloader/pfSecurePreloader.h index 2dd33019..e7356f94 100644 --- a/Sources/Plasma/FeatureLib/pfSecurePreloader/pfSecurePreloader.h +++ b/Sources/Plasma/FeatureLib/pfSecurePreloader/pfSecurePreloader.h @@ -90,7 +90,7 @@ public: plOperationProgress* GetProgressBar() { return fProgress; } - static pfSecurePreloader* GetInstance(); + static pfSecurePreloader* GetInstance() { return fInstance; } static void SetInstance(pfSecurePreloader* instance) { fInstance = instance; } }; diff --git a/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h b/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h index 5680d093..44c9b688 100644 --- a/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h +++ b/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h @@ -208,8 +208,8 @@ struct NetVaultNode : AtomicRef { CCritSect critsect; - uint64_t fieldFlags; - uint64_t dirtyFlags; + uint64_t fieldFlags; + uint64_t dirtyFlags; plUUID revisionId; diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp index 2c631a7f..bbd107da 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp @@ -279,6 +279,13 @@ plNetLinkingMgr::plNetLinkingMgr() { } +plNetLinkingMgr::~plNetLinkingMgr() +{ + std::for_each(s_opqueue.begin(), s_opqueue.end(), + [](NlmOp * op) { delete op; } + ); +} + plNetLinkingMgr * plNetLinkingMgr::GetInstance() { static plNetLinkingMgr Instance; diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.h b/Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.h index 8cf62260..6997c3fb 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.h +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.h @@ -76,7 +76,8 @@ class plNetLinkingMgr plNetLinkingMgr(); - plNetLinkingMgr(const plNetLinkingMgr &); + plNetLinkingMgr(const plNetLinkingMgr &) { } + ~plNetLinkingMgr(); enum Cmds { diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp index 91c84cda..de858553 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp @@ -1053,6 +1053,8 @@ struct ScoreGetScoresTrans : NetAuthTrans { void * param ); + ~ScoreGetScoresTrans(); + bool Send (); void Post (); bool Recv ( @@ -4649,6 +4651,11 @@ ScoreGetScoresTrans::ScoreGetScoresTrans ( StrCopy(m_gameName, gameName, arrsize(m_gameName)); } +//============================================================================ +ScoreGetScoresTrans::~ScoreGetScoresTrans () { + delete[] m_scores; +} + //============================================================================ bool ScoreGetScoresTrans::Send () { if (!AcquireConn()) diff --git a/Sources/Plasma/PubUtilLib/plPipeline/plBinkPlayer.h b/Sources/Plasma/PubUtilLib/plPipeline/plBinkPlayer.h index fd3c8607..588b0134 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/plBinkPlayer.h +++ b/Sources/Plasma/PubUtilLib/plPipeline/plBinkPlayer.h @@ -58,6 +58,7 @@ class plBinkPlayer public: plBinkPlayer() : fFileName(nil) { } + ~plBinkPlayer() { delete [] fFileName; } static bool Init( hsWindowHndl hWnd) { return true; } static bool DeInit() { return true; }