MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / SDL_CreateThreadWithStackSize

Function SDL_CreateThreadWithStackSize

deps/SDL2/src/thread/SDL_thread.c:322–398  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

320 pfnSDL_CurrentEndThread pfnEndThread)
321#else
322SDL_Thread *
323SDL_CreateThreadWithStackSize(int (SDLCALL * fn) (void *),
324 const char *name, const size_t stacksize, void *data)
325#endif
326{
327 SDL_Thread *thread;
328 thread_args *args;
329 int ret;
330
331 /* Allocate memory for the thread info structure */
332 thread = (SDL_Thread *) SDL_malloc(sizeof(*thread));
333 if (thread == NULL) {
334 SDL_OutOfMemory();
335 return (NULL);
336 }
337 SDL_zerop(thread);
338 thread->status = -1;
339 SDL_AtomicSet(&thread->state, SDL_THREAD_STATE_ALIVE);
340
341 /* Set up the arguments for the thread */
342 if (name != NULL) {
343 thread->name = SDL_strdup(name);
344 if (thread->name == NULL) {
345 SDL_OutOfMemory();
346 SDL_free(thread);
347 return (NULL);
348 }
349 }
350
351 /* Set up the arguments for the thread */
352 args = (thread_args *) SDL_malloc(sizeof(*args));
353 if (args == NULL) {
354 SDL_OutOfMemory();
355 if (thread->name) {
356 SDL_free(thread->name);
357 }
358 SDL_free(thread);
359 return (NULL);
360 }
361 args->func = fn;
362 args->data = data;
363 args->info = thread;
364 args->wait = SDL_CreateSemaphore(0);
365 if (args->wait == NULL) {
366 if (thread->name) {
367 SDL_free(thread->name);
368 }
369 SDL_free(thread);
370 SDL_free(args);
371 return (NULL);
372 }
373
374 thread->stacksize = stacksize;
375
376 /* Create the thread and go! */
377#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
378 ret = SDL_SYS_CreateThread(thread, args, pfnBeginThread, pfnEndThread);
379#else

Callers 2

SDL_thread.cFile · 0.85
SDL_CreateThreadInternalFunction · 0.85

Calls 8

SDL_mallocFunction · 0.85
SDL_AtomicSetFunction · 0.85
SDL_strdupFunction · 0.85
SDL_freeFunction · 0.85
SDL_CreateSemaphoreFunction · 0.50
SDL_SYS_CreateThreadFunction · 0.50
SDL_SemWaitFunction · 0.50
SDL_DestroySemaphoreFunction · 0.50

Tested by

no test coverage detected