From d5d4610946d1793d11182fb2e042e766075d74f5 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sat, 21 Jan 2006 23:01:06 +0000 Subject: [PATCH] CString->RString fixes RageFileDriverZip memory corruption --- stepmania/src/RageThreads.cpp | 18 +++++++++--------- stepmania/src/RageThreads.h | 24 ++++++++++++------------ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/stepmania/src/RageThreads.cpp b/stepmania/src/RageThreads.cpp index 6834f05dce..1aa4f31d5f 100644 --- a/stepmania/src/RageThreads.cpp +++ b/stepmania/src/RageThreads.cpp @@ -256,7 +256,7 @@ void RageThread::Create( int (*fn)(void *), void *data ) m_pSlot->pImpl = MakeThread( fn, data, &m_pSlot->id ); } -RageThreadRegister::RageThreadRegister( const CString &sName ) +RageThreadRegister::RageThreadRegister( const RString &sName ) { InitThreads(); LockMut( GetThreadSlotsLock() ); @@ -512,7 +512,7 @@ void RageMutex::MarkLockedMutex() static set *g_FreeMutexIDs = NULL; #endif -RageMutex::RageMutex( const CString name ): +RageMutex::RageMutex( const RString &name ): m_sName( name ) { m_pMutex = MakeMutex( this ); @@ -530,7 +530,7 @@ RageMutex::RageMutex( const CString name ): if( g_FreeMutexIDs->empty() ) { ASSERT_M( g_MutexList, "!g_FreeMutexIDs but !g_MutexList?" ); // doesn't make sense to be out of mutexes yet never created any - CString s; + RString s; for( unsigned i = 0; i < g_MutexList->size(); ++i ) { if( i ) @@ -585,13 +585,13 @@ void RageMutex::Lock() const ThreadSlot *ThisSlot = GetThreadSlotFromID( GetThisThreadId() ); const ThreadSlot *OtherSlot = GetThreadSlotFromID( m_LockedBy ); - CString ThisSlotName = "(???" ")"; // stupid trigraph warnings - CString OtherSlotName = "(???" ")"; // stupid trigraph warnings + RString ThisSlotName = "(???" ")"; // stupid trigraph warnings + RString OtherSlotName = "(???" ")"; // stupid trigraph warnings if( ThisSlot ) ThisSlotName = ssprintf( "%s (%i)", ThisSlot->GetThreadName(), (int) ThisSlot->id ); if( OtherSlot ) OtherSlotName = ssprintf( "%s (%i)", OtherSlot->GetThreadName(), (int) OtherSlot->id ); - const CString sReason = ssprintf( "Thread deadlock on mutex %s between %s and %s", + const RString sReason = ssprintf( "Thread deadlock on mutex %s between %s and %s", GetName().c_str(), ThisSlotName.c_str(), OtherSlotName.c_str() ); #if defined(CRASH_HANDLER) @@ -679,7 +679,7 @@ void LockMutex::Unlock() } } -RageEvent::RageEvent( CString name ): +RageEvent::RageEvent( RString name ): RageMutex( name ) { m_pEvent = MakeEvent( m_pMutex ); @@ -719,7 +719,7 @@ void RageEvent::Broadcast() m_pEvent->Broadcast(); } -RageSemaphore::RageSemaphore( CString sName, int iInitialValue ): +RageSemaphore::RageSemaphore( RString sName, int iInitialValue ): m_sName( sName ) { m_pSema = MakeSemaphore( iInitialValue ); @@ -752,7 +752,7 @@ retry: /* We waited too long. We're probably deadlocked, though unlike mutexes, we can't * tell which thread we're stuck on. */ const ThreadSlot *ThisSlot = GetThreadSlotFromID( GetThisThreadId() ); - const CString sReason = ssprintf( "Semaphore timeout on mutex %s on thread %s", + const RString sReason = ssprintf( "Semaphore timeout on mutex %s on thread %s", GetName().c_str(), ThisSlot? ThisSlot->GetThreadName(): "(???" ")" ); // stupid trigraph warnings #if defined(CRASH_HANDLER) CrashHandler::ForceDeadlock( sReason, GetInvalidThreadId() ); diff --git a/stepmania/src/RageThreads.h b/stepmania/src/RageThreads.h index f042290d01..682e147183 100644 --- a/stepmania/src/RageThreads.h +++ b/stepmania/src/RageThreads.h @@ -11,8 +11,8 @@ public: RageThread(); ~RageThread(); - void SetName( const CString &n ) { name = n; } - CString GetName() const { return name; } + void SetName( const RString &n ) { name = n; } + RString GetName() const { return name; } void Create( int (*fn)(void *), void *data ); /* For crash handlers: kill or suspend all threads (except for @@ -41,7 +41,7 @@ public: private: ThreadSlot *m_pSlot; - CString name; + RString name; static bool s_bSystemSupportsTLS; static bool s_bIsShowingDialog; @@ -52,7 +52,7 @@ private: class RageThreadRegister { public: - RageThreadRegister( const CString &sName ); + RageThreadRegister( const RString &sName ); ~RageThreadRegister(); private: @@ -78,19 +78,19 @@ class MutexImpl; class RageMutex { public: - CString GetName() const { return m_sName; } - void SetName( const CString &s ) { m_sName = s; } + RString GetName() const { return m_sName; } + void SetName( const RString &s ) { m_sName = s; } virtual void Lock(); virtual bool TryLock(); virtual void Unlock(); virtual bool IsLockedByThisThread() const; - RageMutex( CString name ); + RageMutex( const RString &name ); virtual ~RageMutex(); protected: MutexImpl *m_pMutex; - CString m_sName; + RString m_sName; int m_UniqueID; @@ -154,7 +154,7 @@ class EventImpl; class RageEvent: public RageMutex { public: - RageEvent( CString name ); + RageEvent( RString name ); ~RageEvent(); /* @@ -175,10 +175,10 @@ class SemaImpl; class RageSemaphore { public: - RageSemaphore( CString sName, int iInitialValue = 0 ); + RageSemaphore( RString sName, int iInitialValue = 0 ); ~RageSemaphore(); - CString GetName() const { return m_sName; } + RString GetName() const { return m_sName; } int GetValue() const; void Post(); void Wait( bool bFailOnTimeout=true ); @@ -186,7 +186,7 @@ public: private: SemaImpl *m_pSema; - CString m_sName; + RString m_sName; }; #endif