Mercurial > wgsdk
comparison src/timer.c @ 9:07f0e2f43204
*: add the restrict keyword when necessary
also fixed some typos in the README
| author | Paper | 
|---|---|
| date | Fri, 16 Dec 2022 21:55:37 -0500 | 
| parents | be4835547dd0 | 
| children | 42ac054c0231 | 
   comparison
  equal
  deleted
  inserted
  replaced
| 8:00399cc5f7ce | 9:07f0e2f43204 | 
|---|---|
| 3 # define WIN32_LEAN_AND_MEAN | 3 # define WIN32_LEAN_AND_MEAN | 
| 4 #endif | 4 #endif | 
| 5 #include <windows.h> | 5 #include <windows.h> | 
| 6 #include "timer.h" | 6 #include "timer.h" | 
| 7 | 7 | 
| 8 void timer_init(struct timer* timer, HWND winampClientWindow, TIMERPROC timer_proc) { | 8 void timer_init(struct timer* restrict timer, HWND winampClientWindow, TIMERPROC timer_proc) { | 
| 9 timer->winampClientWindow = winampClientWindow; | 9 timer->winampClientWindow = winampClientWindow; | 
| 10 timer->timer_proc = timer_proc; | 10 timer->timer_proc = timer_proc; | 
| 11 timer->initialized = 1; | 11 timer->initialized = 1; | 
| 12 } | 12 } | 
| 13 | 13 | 
| 14 void timer_set(struct timer* timer, HWND winampClientWindow) { | 14 void timer_set(struct timer* restrict timer, HWND winampClientWindow) { | 
| 15 assert(timer->initialized); | 15 assert(timer->initialized); | 
| 16 | 16 | 
| 17 if (timer->is_timer_alive) | 17 if (timer->is_timer_alive) | 
| 18 return; | 18 return; | 
| 19 | 19 | 
| 20 timer->is_timer_alive = 1; | 20 timer->is_timer_alive = 1; | 
| 21 SetTimer(winampClientWindow, 1, timer->interval, timer->timer_proc); | 21 SetTimer(winampClientWindow, 1, timer->interval, timer->timer_proc); | 
| 22 } | 22 } | 
| 23 | 23 | 
| 24 void timer_stop(struct timer* timer, HWND winampClientWindow) { | 24 void timer_stop(struct timer* restrict timer, HWND winampClientWindow) { | 
| 25 assert(timer->initialized); | 25 assert(timer->initialized); | 
| 26 | 26 | 
| 27 if (!timer->is_timer_alive) | 27 if (!timer->is_timer_alive) | 
| 28 return; | 28 return; | 
| 29 | 29 | 
| 30 | |
| 31 timer->is_timer_alive = 0; | 30 timer->is_timer_alive = 0; | 
| 32 KillTimer(winampClientWindow, 1); | 31 KillTimer(winampClientWindow, 1); | 
| 33 } | 32 } | 
