From 265a9693914b0c6a2324f077c38e97e4cf10bf88 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sun, 15 Jul 2012 20:32:50 +0000 Subject: cThread uses AString instead of char * for name (fixed a warning) git-svn-id: http://mc-server.googlecode.com/svn/trunk@670 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cThread.cpp | 24 +++++++++++++++++------- source/cThread.h | 2 +- 2 files changed, 18 insertions(+), 8 deletions(-) (limited to 'source') diff --git a/source/cThread.cpp b/source/cThread.cpp index f07a973b5..3df75f0e7 100644 --- a/source/cThread.cpp +++ b/source/cThread.cpp @@ -45,15 +45,17 @@ cThread::cThread( ThreadFunc a_ThreadFunction, void* a_Param, const char* a_Thre , m_Param( a_Param ) , m_Event( new cEvent() ) , m_StopEvent( 0 ) - , m_ThreadName( 0 ) { if( a_ThreadName ) { - m_ThreadName = new char[ strlen(a_ThreadName)+1 ]; - strcpy(m_ThreadName, a_ThreadName); + m_ThreadName.assign(a_ThreadName); } } + + + + cThread::~cThread() { delete m_Event; @@ -63,10 +65,12 @@ cThread::~cThread() m_StopEvent->Wait(); delete m_StopEvent; } - - delete [] m_ThreadName; } + + + + void cThread::Start( bool a_bWaitOnDelete /* = true */ ) { if( a_bWaitOnDelete ) @@ -86,16 +90,22 @@ void cThread::Start( bool a_bWaitOnDelete /* = true */ ) ,&ThreadID ); // thread id CloseHandle( hThread ); - if( m_ThreadName ) + #ifdef _MSC_VER + if (!m_ThreadName.empty()) { - SetThreadName(ThreadID, m_ThreadName ); + SetThreadName(ThreadID, m_ThreadName.c_str()); } + #endif // _MSC_VER #endif // Wait until thread has actually been created m_Event->Wait(); } + + + + #ifdef _WIN32 unsigned long cThread::MyThread(void* a_Param ) #else diff --git a/source/cThread.h b/source/cThread.h index 5707e4bac..3c9316424 100644 --- a/source/cThread.h +++ b/source/cThread.h @@ -22,5 +22,5 @@ private: cEvent* m_Event; cEvent* m_StopEvent; - char* m_ThreadName; + AString m_ThreadName; }; \ No newline at end of file -- cgit v1.2.3