From 6f883c0f3f4c08fe8e125f269da9b940519ccf44 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Thu, 14 Apr 2011 11:28:22 +0200 Subject: Use generic lists for events. Use the new generic list implementation instead of those insane "next" pointers in events. Includes some cleanups. Signed-off-by: Lukas Fleischer --- src/day.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/day.c') diff --git a/src/day.c b/src/day.c index 9c95ae0..aee71fb 100644 --- a/src/day.c +++ b/src/day.c @@ -150,16 +150,14 @@ day_add_apoint (int type, char *mesg, char *note, long start, long dur, static int day_store_events (long date) { - struct event *j; + llist_item_t *i; int e_nb = 0; - for (j = eventlist; j != NULL; j = j->next) + LLIST_FIND_FOREACH (&eventlist, date, event_inday, i) { - if (event_inday (j, date)) - { - e_nb++; - (void)day_add_event (EVNT, j->mesg, j->note, j->day, j->id); - } + struct event *ev = LLIST_TS_GET_DATA (i); + (void)day_add_event (EVNT, ev->mesg, ev->note, ev->day, ev->id); + e_nb++; } return e_nb; @@ -475,7 +473,6 @@ day_check_if_item (struct date day) { struct recur_event *re; struct recur_apoint *ra; - struct event *e; const long date = date2sec (day, 0, 0); for (re = recur_elist; re != NULL; re = re->next) @@ -493,9 +490,8 @@ day_check_if_item (struct date day) } pthread_mutex_unlock (&(recur_alist_p->mutex)); - for (e = eventlist; e != NULL; e = e->next) - if (event_inday (e, date)) - return (1); + if (LLIST_FIND_FIRST (&eventlist, date, event_inday)) + return (1); LLIST_TS_LOCK (&alist_p); if (LLIST_TS_FIND_FIRST (&alist_p, date, apoint_inday)) -- cgit v1.2.3