summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ivydebug.h1
-rw-r--r--src/timer.c34
2 files changed, 22 insertions, 13 deletions
diff --git a/src/ivydebug.h b/src/ivydebug.h
index ee73f0e..8c43575 100644
--- a/src/ivydebug.h
+++ b/src/ivydebug.h
@@ -15,6 +15,7 @@
#endif
#else
#ifdef DEBUG
+#include <stdio.h>
#define TRACE(format, args...) \
fprintf (stderr, format , ## args)
diff --git a/src/timer.c b/src/timer.c
index 4b07d27..d3ff656 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -153,24 +153,32 @@ void TimerScan()
int timer_echu = 0;
stamp = currentTime();
+
/* recherche des timers echu dans la liste */
IVY_LIST_EACH_SAFE( timers , timer, next )
{
- if ( timer->when <= stamp )
+ if ( timer->when <= stamp )
+ {
+ timer_echu++;
+ delta = stamp - timer->when;
+ /* call callback */
+ (*timer->callback)( timer, timer->user_data, delta );
+ }
+ }
+
+ IVY_LIST_EACH_SAFE( timers , timer, next )
+ {
+ if ( timer->when <= stamp )
+ {
+ if ( timer->repeat == TIMER_LOOP || --(timer->repeat) )
+ {
+ timer->when = stamp + timer->period;
+ }
+ else
{
- timer_echu++;
- delta = stamp - timer->when;
- /* call callback */
- (*timer->callback)( timer, timer->user_data, delta );
- if ( timer->repeat == TIMER_LOOP || --(timer->repeat) )
- {
- timer->when = stamp + timer->period;
- }
- else
- {
- IVY_LIST_REMOVE( timers, timer );
- }
+ IVY_LIST_REMOVE( timers, timer );
}
+ }
}
}