From 19c8614ae87b01ef4f14793c6dd8eb0fc4a558ba Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Wed, 27 Dec 2023 14:14:25 -0500 Subject: [PATCH] No need for _schedule_init() --- src/schedule.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/src/schedule.c b/src/schedule.c index 4925dcc..4a33789 100644 --- a/src/schedule.c +++ b/src/schedule.c @@ -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;