fix gencode: refactor leak the free function
Add pattern State.fsm