Skip to content

Commit

Permalink
windows: created threads' stack sizes should be reserved, not committed.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Apr 12, 2016
1 parent 9b4db2b commit 9b9ca09
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/thread/windows/SDL_systhread.c
Expand Up @@ -121,6 +121,7 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
#endif /* SDL_PASSED_BEGINTHREAD_ENDTHREAD */
pThreadStartParms pThreadParms =
(pThreadStartParms) SDL_malloc(sizeof(tThreadStartParms));
const DWORD flags = thread->stacksize ? STACK_SIZE_PARAM_IS_A_RESERVATION : 0;
if (!pThreadParms) {
return SDL_OutOfMemory();
}
Expand All @@ -135,12 +136,12 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
thread->handle = (SYS_ThreadHandle)
((size_t) pfnBeginThread(NULL, (unsigned int) thread->stacksize,
RunThreadViaBeginThreadEx,
pThreadParms, 0, &threadid));
pThreadParms, flags, &threadid));
} else {
DWORD threadid = 0;
thread->handle = CreateThread(NULL, thread->stacksize,
RunThreadViaCreateThread,
pThreadParms, 0, &threadid);
pThreadParms, flags, &threadid);
}
if (thread->handle == NULL) {
return SDL_SetError("Not enough resources to create thread");
Expand Down

0 comments on commit 9b9ca09

Please sign in to comment.