No need for _schedule_init()

This commit is contained in:
XANTRONIX Development 2023-12-27 14:14:25 -05:00
parent 80cc0f663d
commit 19c8614ae8

View file

@ -65,12 +65,16 @@ static void _ev_notify(union sigval sv) {
_slot_set_interval(schedule, schedule->current);
}
static int _schedule_init(hexagram_schedule *schedule,
hexagram_schedule_table_entry *table,
size_t count,
void *ctx) {
hexagram_schedule *hexagram_schedule_create(hexagram_schedule_table_entry *table,
size_t count,
void *ctx) {
hexagram_schedule *schedule;
size_t i;
if ((schedule = malloc(sizeof(*schedule) + count * sizeof(hexagram_schedule_slot))) == 0) {
goto error_malloc_schedule;
}
memset(schedule, '\0', sizeof(*schedule));
schedule->current = 0;
@ -96,24 +100,10 @@ static int _schedule_init(hexagram_schedule *schedule,
qsort(schedule + 1, count, sizeof(hexagram_schedule_slot), _slot_cmp);
return 0;
return schedule;
error_timer_create:
return -1;
}
hexagram_schedule *hexagram_schedule_create(hexagram_schedule_table_entry *table,
size_t count,
void *ctx) {
hexagram_schedule *schedule;
if ((schedule = malloc(sizeof(*schedule) + count * sizeof(hexagram_schedule_slot))) == 0) {
goto error_malloc_schedule;
}
_schedule_init(schedule, table, count, ctx);
return schedule;
free(schedule);
error_malloc_schedule:
return NULL;