fsm: use stdlib.h instead of malloc.h for better compat