diff --git a/src/schedule.c b/src/schedule.c new file mode 100644 index 0000000..2ec5842 --- /dev/null +++ b/src/schedule.c @@ -0,0 +1,36 @@ +#include + +#include + +hexagram_schedule *hexagram_schedule_create(hexagram_table_entry *table, + size_t count) { + hexagram_schedule *schedule; + size_t i; + + if ((schedule = malloc(sizeof(*schedule) + count * sizeof(hexagram_schedule_slot))) == 0) { + goto error_malloc_schedule; + } + + schedule->timer = NULL; + schedule->current = 0; + + for (i=0; iinterval_us = 0; + slot->entry = &table[i]; + } + + return schedule; + +error_malloc_schedule: + return NULL; +} + +void hexagram_schedule_destroy(hexagram_schedule *schedule) { + if (schedule->timer) { + timer_delete(schedule->timer); + } + + free(schedule); +}