Use shared_ptr and references for Actions.
This slows terminal emulation slightly.
This commit is contained in:
@@ -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 )
|
||||
{}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user