From: Martin Mares Date: Tue, 30 Oct 2012 20:39:43 +0000 (+0100) Subject: Mainloop: Fixed position tracking in timer heaps X-Git-Tag: v5.99~94 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=41db262c607b7987583494004dbfa467d2a70da7;p=libucw.git Mainloop: Fixed position tracking in timer heaps --- diff --git a/ucw/mainloop.c b/ucw/mainloop.c index e2b96826..b5e54965 100644 --- a/ucw/mainloop.c +++ b/ucw/mainloop.c @@ -259,9 +259,9 @@ timer_add(struct main_timer *tm, timestamp_t expires) if (!tm->expires) { tm->expires = expires; - tm->index = num_timers; + tm->index = num_timers + 1; GARY_RESIZE(m->timer_table, num_timers + 2); - HEAP_INSERT(struct main_timer *, m->timer_table, tm->index, MAIN_TIMER_LESS, MAIN_TIMER_SWAP, tm); + HEAP_INSERT(struct main_timer *, m->timer_table, num_timers, MAIN_TIMER_LESS, MAIN_TIMER_SWAP, tm); } else {