The if condition within the `sched_run` is the one thing (I'm not really happy about, either, but that's probably bearable), but re-introducint malloc/free into core again, seems a bad idea to me. Apart from the dependency to dynamic memory management, I guess, that most implementations of `free()` have non-determistic runtime, thus breaking real-time guarantees.