From 5b1d21d1a15d9dbe7c9dc3e720993817fbd8a465 Mon Sep 17 00:00:00 2001 From: Sonicadvance1 Date: Sun, 14 Feb 2010 14:06:33 +0000 Subject: =?UTF-8?q?Bunch=20of=20tiny=20memory=20leaks=20fixed=20and=20clea?= =?UTF-8?q?nup,=20=E3=83=95=E3=82=A6=E3=80=9C=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5056 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/Thread.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Source/Core/Common/Src/Thread.cpp') 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); } -- cgit v1.2.3