Timer clean-up improvements and some mem.c sanity checks.

This commit is contained in:
OBattler
2020-05-20 20:35:55 +02:00
parent 319d55f0ea
commit fc28978370
3 changed files with 21 additions and 7 deletions

View File

@@ -110,8 +110,10 @@ timer_remove_head(void)
if (timer_head) {
timer = timer_head;
timer_head = timer->next;
if (timer_head)
if (timer_head) {
timer_head->prev = NULL;
timer->next->prev = NULL;
}
timer->next = timer->prev = NULL;
timer->flags &= ~TIMER_ENABLED;
}
@@ -151,6 +153,17 @@ timer_process(void)
void
timer_close(void)
{
pc_timer_t *t = timer_head, *r;
/* Set all timers' prev and next to NULL so it is assured that
timers that are not in malloc'd structs don't keep pointing
to timers that may be in malloc'd structs. */
while (t != NULL) {
r = t;
r->prev = r->next = NULL;
t = r->next;
}
timer_head = NULL;
timer_inited = 0;