No need for _schedule_init()
This commit is contained in:
parent
80cc0f663d
commit
19c8614ae8
1 changed files with 10 additions and 20 deletions
|
@ -65,12 +65,16 @@ static void _ev_notify(union sigval sv) {
|
||||||
_slot_set_interval(schedule, schedule->current);
|
_slot_set_interval(schedule, schedule->current);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _schedule_init(hexagram_schedule *schedule,
|
hexagram_schedule *hexagram_schedule_create(hexagram_schedule_table_entry *table,
|
||||||
hexagram_schedule_table_entry *table,
|
|
||||||
size_t count,
|
size_t count,
|
||||||
void *ctx) {
|
void *ctx) {
|
||||||
|
hexagram_schedule *schedule;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
if ((schedule = malloc(sizeof(*schedule) + count * sizeof(hexagram_schedule_slot))) == 0) {
|
||||||
|
goto error_malloc_schedule;
|
||||||
|
}
|
||||||
|
|
||||||
memset(schedule, '\0', sizeof(*schedule));
|
memset(schedule, '\0', sizeof(*schedule));
|
||||||
|
|
||||||
schedule->current = 0;
|
schedule->current = 0;
|
||||||
|
@ -96,24 +100,10 @@ static int _schedule_init(hexagram_schedule *schedule,
|
||||||
|
|
||||||
qsort(schedule + 1, count, sizeof(hexagram_schedule_slot), _slot_cmp);
|
qsort(schedule + 1, count, sizeof(hexagram_schedule_slot), _slot_cmp);
|
||||||
|
|
||||||
return 0;
|
return schedule;
|
||||||
|
|
||||||
error_timer_create:
|
error_timer_create:
|
||||||
return -1;
|
free(schedule);
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
error_malloc_schedule:
|
error_malloc_schedule:
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Add table
Reference in a new issue