Commit 93eceba0 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Move freeing the thread stack to a common helper.

parent 6f790606
......@@ -944,14 +944,8 @@ NTSTATUS signal_alloc_thread( TEB **teb )
*/
void signal_free_thread( TEB *teb )
{
SIZE_T size;
SIZE_T size = 0;
if (teb->DeallocationStack)
{
size = 0;
NtFreeVirtualMemory( GetCurrentProcess(), &teb->DeallocationStack, &size, MEM_RELEASE );
}
size = 0;
NtFreeVirtualMemory( NtCurrentProcess(), (void **)&teb, &size, MEM_RELEASE );
}
......
......@@ -817,14 +817,8 @@ NTSTATUS signal_alloc_thread( TEB **teb )
*/
void signal_free_thread( TEB *teb )
{
SIZE_T size;
SIZE_T size = 0;
if (teb->DeallocationStack)
{
size = 0;
NtFreeVirtualMemory( GetCurrentProcess(), &teb->DeallocationStack, &size, MEM_RELEASE );
}
size = 0;
NtFreeVirtualMemory( NtCurrentProcess(), (void **)&teb, &size, MEM_RELEASE );
}
......
......@@ -2504,16 +2504,10 @@ NTSTATUS signal_alloc_thread( TEB **teb )
*/
void signal_free_thread( TEB *teb )
{
SIZE_T size;
SIZE_T size = 0;
struct x86_thread_data *thread_data = (struct x86_thread_data *)teb->SystemReserved2;
if (thread_data) wine_ldt_free_fs( thread_data->fs );
if (teb->DeallocationStack)
{
size = 0;
NtFreeVirtualMemory( GetCurrentProcess(), &teb->DeallocationStack, &size, MEM_RELEASE );
}
size = 0;
wine_ldt_free_fs( thread_data->fs );
NtFreeVirtualMemory( NtCurrentProcess(), (void **)&teb, &size, MEM_RELEASE );
}
......
......@@ -1023,14 +1023,8 @@ NTSTATUS signal_alloc_thread( TEB **teb )
*/
void signal_free_thread( TEB *teb )
{
SIZE_T size;
SIZE_T size = 0;
if (teb->DeallocationStack)
{
size = 0;
NtFreeVirtualMemory( GetCurrentProcess(), &teb->DeallocationStack, &size, MEM_RELEASE );
}
size = 0;
NtFreeVirtualMemory( NtCurrentProcess(), (void **)&teb, &size, MEM_RELEASE );
}
......
......@@ -2983,14 +2983,8 @@ NTSTATUS signal_alloc_thread( TEB **teb )
*/
void signal_free_thread( TEB *teb )
{
SIZE_T size;
SIZE_T size = 0;
if (teb->DeallocationStack)
{
size = 0;
NtFreeVirtualMemory( GetCurrentProcess(), &teb->DeallocationStack, &size, MEM_RELEASE );
}
size = 0;
NtFreeVirtualMemory( NtCurrentProcess(), (void **)&teb, &size, MEM_RELEASE );
}
......
......@@ -404,6 +404,22 @@ HANDLE thread_init(void)
/***********************************************************************
* free_thread_data
*/
static void free_thread_data( TEB *teb )
{
SIZE_T size;
if (teb->DeallocationStack)
{
size = 0;
NtFreeVirtualMemory( GetCurrentProcess(), &teb->DeallocationStack, &size, MEM_RELEASE );
}
signal_free_thread( teb );
}
/***********************************************************************
* terminate_thread
*/
void terminate_thread( int status )
......@@ -456,7 +472,7 @@ void exit_thread( int status )
if (thread_data->pthread_id)
{
pthread_join( thread_data->pthread_id, NULL );
signal_free_thread( teb );
free_thread_data( teb );
}
}
......@@ -634,7 +650,7 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, const SECURITY_DESCRIPTOR *
return STATUS_SUCCESS;
error:
if (teb) signal_free_thread( teb );
if (teb) free_thread_data( teb );
if (handle) NtClose( handle );
pthread_sigmask( SIG_SETMASK, &sigset, NULL );
close( request_pipe[1] );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment