MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / SDL_RemoveTimer

Function SDL_RemoveTimer

lib/sdl2/src/timer/SDL_timer.c:341–371  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

339}
340
341SDL_bool
342SDL_RemoveTimer(SDL_TimerID id)
343{
344 SDL_TimerData *data = &SDL_timer_data;
345 SDL_TimerMap *prev, *entry;
346 SDL_bool canceled = SDL_FALSE;
347
348 /* Find the timer */
349 SDL_LockMutex(data->timermap_lock);
350 prev = NULL;
351 for (entry = data->timermap; entry; prev = entry, entry = entry->next) {
352 if (entry->timerID == id) {
353 if (prev) {
354 prev->next = entry->next;
355 } else {
356 data->timermap = entry->next;
357 }
358 break;
359 }
360 }
361 SDL_UnlockMutex(data->timermap_lock);
362
363 if (entry) {
364 if (!SDL_AtomicGet(&entry->timer->canceled)) {
365 SDL_AtomicSet(&entry->timer->canceled, 1);
366 canceled = SDL_TRUE;
367 }
368 SDL_free(entry);
369 }
370 return canceled;
371}
372
373/* vi: set ts=4 sw=4 expandtab: */

Callers 4

timer_addRemoveTimerFunction · 0.85
mainFunction · 0.85
SDLTest_RunTestFunction · 0.85
SDL_AddTimerFunction · 0.85

Calls 5

SDL_AtomicGetFunction · 0.85
SDL_AtomicSetFunction · 0.85
SDL_freeFunction · 0.85
SDL_LockMutexFunction · 0.50
SDL_UnlockMutexFunction · 0.50

Tested by 3

timer_addRemoveTimerFunction · 0.68
mainFunction · 0.68
SDLTest_RunTestFunction · 0.68