|
|
void
|
void
|
GsAddTimer(struct GsTimer* newtimer) {
|
GsAddTimer(struct GsTimer* newtimer) {
|
int i;
|
int i;
|
struct GsTimer* curTimer;
|
struct GsTimer* curTimer;
|
if(our_timers.numof++>0) {
|
if(our_timers.numof++>0) {
|
curTimer=our_timer->head;
|
curTimer=our_timer->head;
|
for(curTimer=our_timer->head;curTimer!=NULL;curTimer=curTimer->next) {
|
for(curTimer=our_timer->head;curTimer!=NULL;curTimer=curTimer->next) {
|
if(curTimer->due>newtimer->due) { /* time to file it away... */
|
if(curTimer->due>newtimer->due) { /* time to file it away... */
|
if(our_timer->head==curTimer) { /* put it at the beginning... */
|
if(our_timer->head==curTimer) { /* put it at the beginning... */
|
newtimer->next=our_timer->head;
|
newtimer->next=our_timer->head;
|
our_timer->head=newtimer;
|
our_timer->head=newtimer;
|
return;
|
return;
|
} /* else put it in the middle... */
|
} /* else put it in the middle... */
|
newtimer->next=curTimer;
|
newtimer->next=curTimer;
|
prevTimer->next=newtimer;
|
prevTimer->next=newtimer;
|
return;
|
return;
|
}
|
}
|
prevTimer=curTimer;
|
prevTimer=curTimer;
|
} /* else put it at the end... */
|
} /* else put it at the end... */
|
our_timer->tail->next=newtimer;
|
our_timer->tail->next=newtimer;
|
our_timer->tail=newtimer;
|
our_timer->tail=newtimer;
|
newtimer->next=NULL;
|
newtimer->next=NULL;
|
return;
|
return;
|
} /* else... hey it's the first timer! */
|
} /* else... hey it's the first timer! */
|
our_timer->head=newtimer;
|
our_timer->head=newtimer;
|
our_timer->tail=newtimer;
|
our_timer->tail=newtimer;
|
newtimer->next=NULL;
|
newtimer->next=NULL;
|
}
|
}
|
|
|