summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Src/Thread.cpp
diff options
context:
space:
mode:
authorSonicadvance1 <sonicadvance1@gmail.com>2010-02-14 14:06:33 +0000
committerSonicadvance1 <sonicadvance1@gmail.com>2010-02-14 14:06:33 +0000
commit5b1d21d1a15d9dbe7c9dc3e720993817fbd8a465 (patch)
tree39448f719e5ac4f05c91cad0760e3302345adbe6 /Source/Core/Common/Src/Thread.cpp
parentb6aa5d91c0c672c42d2531c8189179089567acc6 (diff)
Bunch of tiny memory leaks fixed and cleanup, フウ〜!
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5056 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common/Src/Thread.cpp')
-rw-r--r--Source/Core/Common/Src/Thread.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/Source/Core/Common/Src/Thread.cpp b/Source/Core/Common/Src/Thread.cpp
index 37f52e9ce9..87522a87f6 100644
--- a/Source/Core/Common/Src/Thread.cpp
+++ b/Source/Core/Common/Src/Thread.cpp
@@ -416,7 +416,14 @@ void SleepCurrentThread(int ms)
void SetCurrentThreadName(const TCHAR* szThreadName)
{
- pthread_setspecific(threadname_key, strdup(szThreadName));
+ char *name = strdup(szThreadName);
+ // pthread_setspecific returns 0 on success
+ // free the string from strdup if fails
+ // creates a memory leak if it actually doesn't fail
+ // since we don't delete it once we delete the thread
+ // we are using a single threadname_key anyway for all threads
+ if(!pthread_setspecific(threadname_key, strdup(szThreadName)))
+ free(name);
INFO_LOG(COMMON, "%s(%s)\n", __FUNCTION__, szThreadName);
}