]> git.sesse.net Git - vlc/commitdiff
Win32(core): do not duplicate handle
authorErwan Tulou <erwan10@videolan.org>
Wed, 10 Feb 2010 12:19:42 +0000 (13:19 +0100)
committerErwan Tulou <erwan10@videolan.org>
Thu, 10 Jun 2010 21:23:41 +0000 (23:23 +0200)
Unlike _endthread and ExitThread, _endthreadex doesn't close the handle.
It is therefore up to the caller to close it. Hence no need for an extra
handle duplication (that mostly amounted to a memory leak when the normal
 path was used, i.e normal return from thread with implicit _endthreadex)

src/win32/thread.c

index b2e939d0f3193034053faab0fe453792c37a1868..1d25b90320dcbb061e7f5e3d37aad0a93e8a2283 100644 (file)
@@ -553,15 +553,7 @@ int vlc_clone (vlc_thread_t *p_handle, void * (*entry) (void *), void *data,
         goto error;
     }
 
-    /* Thread closes the handle when exiting, duplicate it here
-     * to be on the safe side when joining. */
-    if (!DuplicateHandle (GetCurrentProcess (), hThread,
-                          GetCurrentProcess (), p_handle, 0, FALSE,
-                          DUPLICATE_SAME_ACCESS))
-    {
-        CloseHandle (hThread);
-        goto error;
-    }
+    *p_handle = hThread;
 
 #else
     vlc_thread_t th = malloc (sizeof (*th));