Skip to content

Commit

Permalink
Added defaults parameters, solved initialization bug that causes crash
Browse files Browse the repository at this point in the history
Signed-off-by: Fabiano Riccardi <fabiuz4@hotmail.it>
  • Loading branch information
Fabiano Riccardi committed Mar 20, 2019
1 parent 55a1971 commit 82a6853
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Fsm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ State::State(void (*on_enter)(), void (*on_state)(), void (*on_exit)())

Fsm::Fsm(State* initial_state)
: m_current_state(initial_state),
m_transitions(NULL),
m_transitions(nullptr),
m_num_transitions(0),
m_timed_transitions(nullptr),
m_num_timed_transitions(0),
m_initialized(false)
{
Expand Down
6 changes: 3 additions & 3 deletions Fsm.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

struct State
{
State(void (*on_enter)(), void (*on_state)(), void (*on_exit)());
State(void (*on_enter)(), void (*on_state)() = nullptr, void (*on_exit)() = nullptr);
void (*on_enter)();
void (*on_state)();
void (*on_exit)();
Expand All @@ -40,10 +40,10 @@ class Fsm
~Fsm();

void add_transition(State* state_from, State* state_to, int event,
void (*on_transition)());
void (*on_transition)() = nullptr);

void add_timed_transition(State* state_from, State* state_to,
unsigned long interval, void (*on_transition)());
unsigned long interval, void (*on_transition)() = nullptr);

void check_timed_transitions();

Expand Down

0 comments on commit 82a6853

Please sign in to comment.