I\'ve been trying to wrap my head around this the whole day...
Basically, I have a struct called State that has a name and another one called StateMachine with a name, a
Inside of your add_state function:
temp = malloc(sizeof(struct StateMachine));
should be
temp = malloc(sizeof(struct State));
However, even when this is changed, I still get the proper output:
--> [0] state: Init
--> [1] state: Foo
--> [2] state: Bar
Perhaps there's nothing wrong with your code. I'm using gcc version 4.4.3