Skip to content

Commit cb0078a

Browse files
committed
Put a single event on the recycle queue initially to avoid runtime calloc
1 parent d454505 commit cb0078a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

core/reactor_common.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,14 @@ void _lf_initialize_timers(environment_t* env) {
549549
_lf_initialize_timer(env, env->timer_triggers[i]);
550550
}
551551
}
552+
553+
// Create an extra event and put it on the recycle queue.
554+
// An LF program with n timers require n+1 events and the last event
555+
// needs to be initialized to the event recycle queue.
556+
if (env->timer_triggers_size > 0) {
557+
event_t *e = _lf_get_new_event(env);
558+
_lf_recycle_event(env, e);
559+
}
552560
}
553561

554562
/**

0 commit comments

Comments
 (0)