mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-20 22:16:49 +01:00
windows: created threads' stack sizes should be reserved, not committed.
This commit is contained in:
parent
9b4db2b8aa
commit
9b9ca093c7
@ -121,6 +121,7 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
|
|||||||
#endif /* SDL_PASSED_BEGINTHREAD_ENDTHREAD */
|
#endif /* SDL_PASSED_BEGINTHREAD_ENDTHREAD */
|
||||||
pThreadStartParms pThreadParms =
|
pThreadStartParms pThreadParms =
|
||||||
(pThreadStartParms) SDL_malloc(sizeof(tThreadStartParms));
|
(pThreadStartParms) SDL_malloc(sizeof(tThreadStartParms));
|
||||||
|
const DWORD flags = thread->stacksize ? STACK_SIZE_PARAM_IS_A_RESERVATION : 0;
|
||||||
if (!pThreadParms) {
|
if (!pThreadParms) {
|
||||||
return SDL_OutOfMemory();
|
return SDL_OutOfMemory();
|
||||||
}
|
}
|
||||||
@ -135,12 +136,12 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
|
|||||||
thread->handle = (SYS_ThreadHandle)
|
thread->handle = (SYS_ThreadHandle)
|
||||||
((size_t) pfnBeginThread(NULL, (unsigned int) thread->stacksize,
|
((size_t) pfnBeginThread(NULL, (unsigned int) thread->stacksize,
|
||||||
RunThreadViaBeginThreadEx,
|
RunThreadViaBeginThreadEx,
|
||||||
pThreadParms, 0, &threadid));
|
pThreadParms, flags, &threadid));
|
||||||
} else {
|
} else {
|
||||||
DWORD threadid = 0;
|
DWORD threadid = 0;
|
||||||
thread->handle = CreateThread(NULL, thread->stacksize,
|
thread->handle = CreateThread(NULL, thread->stacksize,
|
||||||
RunThreadViaCreateThread,
|
RunThreadViaCreateThread,
|
||||||
pThreadParms, 0, &threadid);
|
pThreadParms, flags, &threadid);
|
||||||
}
|
}
|
||||||
if (thread->handle == NULL) {
|
if (thread->handle == NULL) {
|
||||||
return SDL_SetError("Not enough resources to create thread");
|
return SDL_SetError("Not enough resources to create thread");
|
||||||
|
Loading…
Reference in New Issue
Block a user