exec_get_current_version returns string out of scope

Changed Trick::Executive::get_current_version to return a const reference
to the string that holds the version.  This avoids a copy of the string object
and avoids that object going out of scope.  As a string, the debug_command
had the same problem so I fixed that one as well.

refs #252
This commit is contained in:
Alex Lin 2016-06-21 16:03:15 -05:00
parent 75fb095960
commit d9f1780939
2 changed files with 4 additions and 4 deletions

View File

@ -297,7 +297,7 @@ namespace Trick {
@code <my_char*> = trick.exec_get_current_version() @endcode
@return string (C const char*) Executive::current_version
*/
std::string get_current_version() ;
const std::string & get_current_version() ;
/**
@userdesc Command to get the debugger command value.
@ -305,7 +305,7 @@ namespace Trick {
@code <my_char*> = trick.exec_get_debugger_command() @endcode
@return string (C const char*) Executive::debugger_command
*/
std::string get_debugger_command() ;
const std::string & get_debugger_command() ;
/**
@userdesc Command to get the current Executive Mode command.

View File

@ -144,11 +144,11 @@ bool Trick::Executive::get_attach_debugger() {
return(attach_debugger) ;
}
std::string Trick::Executive::get_current_version() {
const std::string & Trick::Executive::get_current_version() {
return(current_version) ;
}
std::string Trick::Executive::get_debugger_command() {
const std::string & Trick::Executive::get_debugger_command() {
return(debugger_command) ;
}