windows: created threads' stack sizes should be reserved, not committed.
authorRyan C. Gordon <icculus@icculus.org>
Tue, 12 Apr 2016 18:12:04 -0400
changeset 101484ed1bd3724d6
parent 10147 ddbdc9c1b92f
child 10149 0188c3322435
windows: created threads' stack sizes should be reserved, not committed.
src/thread/windows/SDL_systhread.c
     1.1 --- a/src/thread/windows/SDL_systhread.c	Tue Apr 12 18:11:36 2016 -0400
     1.2 +++ b/src/thread/windows/SDL_systhread.c	Tue Apr 12 18:12:04 2016 -0400
     1.3 @@ -121,6 +121,7 @@
     1.4  #endif /* SDL_PASSED_BEGINTHREAD_ENDTHREAD */
     1.5      pThreadStartParms pThreadParms =
     1.6          (pThreadStartParms) SDL_malloc(sizeof(tThreadStartParms));
     1.7 +    const DWORD flags = thread->stacksize ? STACK_SIZE_PARAM_IS_A_RESERVATION : 0;
     1.8      if (!pThreadParms) {
     1.9          return SDL_OutOfMemory();
    1.10      }
    1.11 @@ -135,12 +136,12 @@
    1.12          thread->handle = (SYS_ThreadHandle)
    1.13              ((size_t) pfnBeginThread(NULL, (unsigned int) thread->stacksize,
    1.14                                       RunThreadViaBeginThreadEx,
    1.15 -                                     pThreadParms, 0, &threadid));
    1.16 +                                     pThreadParms, flags, &threadid));
    1.17      } else {
    1.18          DWORD threadid = 0;
    1.19          thread->handle = CreateThread(NULL, thread->stacksize,
    1.20                                        RunThreadViaCreateThread,
    1.21 -                                      pThreadParms, 0, &threadid);
    1.22 +                                      pThreadParms, flags, &threadid);
    1.23      }
    1.24      if (thread->handle == NULL) {
    1.25          return SDL_SetError("Not enough resources to create thread");