Module: wine Branch: master Commit: 93eceba03e8a29a622a3f145dd5c157062f37293 URL: http://source.winehq.org/git/wine.git/?a=commit;h=93eceba03e8a29a622a3f145dd...
Author: Alexandre Julliard julliard@winehq.org Date: Wed Nov 29 10:43:39 2017 +0100
ntdll: Move freeing the thread stack to a common helper.
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/ntdll/signal_arm.c | 8 +------- dlls/ntdll/signal_arm64.c | 8 +------- dlls/ntdll/signal_i386.c | 10 ++-------- dlls/ntdll/signal_powerpc.c | 8 +------- dlls/ntdll/signal_x86_64.c | 8 +------- dlls/ntdll/thread.c | 20 ++++++++++++++++++-- 6 files changed, 24 insertions(+), 38 deletions(-)
diff --git a/dlls/ntdll/signal_arm.c b/dlls/ntdll/signal_arm.c index bbd6c59..2102dd0 100644 --- a/dlls/ntdll/signal_arm.c +++ b/dlls/ntdll/signal_arm.c @@ -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 ); }
diff --git a/dlls/ntdll/signal_arm64.c b/dlls/ntdll/signal_arm64.c index 5b3e887..7f2977d 100644 --- a/dlls/ntdll/signal_arm64.c +++ b/dlls/ntdll/signal_arm64.c @@ -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 ); }
diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c index 4038436..671c35f 100644 --- a/dlls/ntdll/signal_i386.c +++ b/dlls/ntdll/signal_i386.c @@ -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 ); }
diff --git a/dlls/ntdll/signal_powerpc.c b/dlls/ntdll/signal_powerpc.c index e5a009c..2d3bd0a 100644 --- a/dlls/ntdll/signal_powerpc.c +++ b/dlls/ntdll/signal_powerpc.c @@ -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 ); }
diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c index 691ee1f..a052a48 100644 --- a/dlls/ntdll/signal_x86_64.c +++ b/dlls/ntdll/signal_x86_64.c @@ -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 ); }
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c index 511fd94..9c7cd13 100644 --- a/dlls/ntdll/thread.c +++ b/dlls/ntdll/thread.c @@ -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] );