| 339 | } |
| 340 | |
| 341 | SDL_bool |
| 342 | SDL_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: */ |