Use shared_ptr and references for Actions.

This slows terminal emulation slightly.
This commit is contained in:
John Hood
2017-05-11 01:22:12 -04:00
parent c6c7f09954
commit 42d2b5d029
13 changed files with 104 additions and 113 deletions
+3 -9
View File
@@ -45,7 +45,7 @@ namespace Parser {
public:
// Transition is only a courier for an Action; it should
// never create/delete one on its own.
Action *action;
ActionPointer action;
State *next_state;
Transition( const Transition &x )
@@ -58,20 +58,14 @@ namespace Parser {
return *this;
}
virtual ~Transition()
{
// Indicate to checkers that we don't own *action anymore
action = NULL;
}
Transition( Action *s_action=new Ignore, State *s_next_state=NULL )
Transition( ActionPointer s_action=shared::make_shared< Ignore >(), State *s_next_state=NULL )
: action( s_action ), next_state( s_next_state )
{}
// This is only ever used in the 1-argument form;
// we use this instead of an initializer to
// tell Coverity the object never owns *action.
Transition( State *s_next_state, Action *s_action=new Ignore )
Transition( State *s_next_state, ActionPointer s_action=shared::make_shared< Ignore >() )
: action( s_action ), next_state( s_next_state )
{}
};