X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Fmainloop.c;h=b5e54965bb87de3e8fab2b3ba877b4c491553832;hb=c0e08a14cb5681faac6bd4b2567fe153f2421273;hp=a8bf0e5e99eb40efe8e298d85f4523c1abde0405;hpb=fa7aa6d9457616ce28f97c83eaa616d0ff276870;p=libucw.git diff --git a/ucw/mainloop.c b/ucw/mainloop.c index a8bf0e5e..b5e54965 100644 --- a/ucw/mainloop.c +++ b/ucw/mainloop.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -259,13 +260,13 @@ timer_add(struct main_timer *tm, timestamp_t expires) { tm->expires = expires; tm->index = num_timers + 1; - *GARY_PUSH(m->timer_table, 1) = tm; - HEAP_INSERT(struct main_timer *, m->timer_table, tm->index, MAIN_TIMER_LESS, MAIN_TIMER_SWAP); + GARY_RESIZE(m->timer_table, num_timers + 2); + HEAP_INSERT(struct main_timer *, m->timer_table, num_timers, MAIN_TIMER_LESS, MAIN_TIMER_SWAP, tm); } else { tm->expires = expires; - HEAP_INCREASE(struct main_timer *, m->timer_table, num_timers, MAIN_TIMER_LESS, MAIN_TIMER_SWAP, tm->index); + HEAP_INCREASE(struct main_timer *, m->timer_table, num_timers, MAIN_TIMER_LESS, MAIN_TIMER_SWAP, tm->index, tm); } } else if (tm->expires > expires) @@ -281,7 +282,7 @@ timer_add(struct main_timer *tm, timestamp_t expires) else { tm->expires = expires; - HEAP_DECREASE(struct main_timer *, m->timer_table, num_timers, MAIN_TIMER_LESS, MAIN_TIMER_SWAP, tm->index); + HEAP_DECREASE(struct main_timer *, m->timer_table, num_timers, MAIN_TIMER_LESS, MAIN_TIMER_SWAP, tm->index, tm); } } }