]> mj.ucw.cz Git - libucw.git/commitdiff
Main: No more calls to GARY_SIZE on an empty timer array
authorMartin Mares <mj@ucw.cz>
Fri, 8 Oct 2010 13:01:12 +0000 (15:01 +0200)
committerMartin Mares <mj@ucw.cz>
Fri, 8 Oct 2010 13:01:12 +0000 (15:01 +0200)
ucw/mainloop.c

index 561ddd3d691a1cdea055f9dc10a85482dd677d1a..0af9bf14ddc21f15c8af9a8ce50be658d1237d0b 100644 (file)
@@ -163,7 +163,10 @@ main_get_time(void)
 static inline uns
 count_timers(struct main_context *m)
 {
-  return GARY_SIZE(m->timer_table) - 1;
+  if (m->timer_table)
+    return GARY_SIZE(m->timer_table) - 1;
+  else
+    return 0;
 }
 
 void
@@ -562,7 +565,7 @@ static void
 process_timers(struct main_context *m)
 {
   struct main_timer *tm;
-  while (GARY_SIZE(m->timer_table) > 1 && (tm = m->timer_table[1])->expires <= m->now)
+  while (count_timers(m) && (tm = m->timer_table[1])->expires <= m->now)
     {
       DBG("MAIN: Timer %p expired at now-%lld", tm, (long long)(m->now - tm->expires));
       tm->handler(tm);