diff --git a/src/aevol_create.cpp b/src/aevol_create.cpp index bde90fed4ba9a7e4bd6fe02cb174ff7a51c72e5a..946b1a44c5e9e7183d4bb6199e671d9f279f2b5b 100644 --- a/src/aevol_create.cpp +++ b/src/aevol_create.cpp @@ -28,8 +28,6 @@ * \brief */ -const char* DEFAULT_PARAM_FILE_NAME = "param.in"; - // ============================================================================ // Includes // ============================================================================ @@ -50,6 +48,8 @@ const char* DEFAULT_PARAM_FILE_NAME = "param.in"; #include "parameters/ParamLoader.h" #include "parameters/ParamReader.h" +const std::string DEFAULT_PARAM_FILE_NAME = "param.in"; + using namespace aevol; // Helper functions @@ -57,7 +57,7 @@ void print_help(char* prog_path); void interpret_cmd_line_options(int argc, char* argv[]); // Command-line option variables -static char* param_file_name = nullptr; +static std::string param_file_name; static std::string chromosome_file_name; int main(int argc, char* argv[]) { @@ -66,9 +66,8 @@ int main(int argc, char* argv[]) { // Print the hash and date of the commit used to compile this executable printf("Running aevol version %s\n", version_string); - assert(param_file_name != nullptr); // Read the parameter file - ParamValues param_values = ParamReader::read_file(param_file_name); + ParamValues param_values = ParamReader::read_file(param_file_name.c_str()); // Initialize the experiment manager exp_manager = new ExpManager(); @@ -99,7 +98,6 @@ int main(int argc, char* argv[]) { exp_manager->Save(true); delete exp_manager; - delete[] param_file_name; } @@ -174,8 +172,7 @@ void interpret_cmd_line_options(int argc, char* argv[]) { exit(EXIT_SUCCESS); } case 'f' : { - param_file_name = new char[strlen(optarg) + 1]; - strcpy(param_file_name, optarg); + param_file_name = optarg; break; } case 'C': { @@ -191,8 +188,7 @@ void interpret_cmd_line_options(int argc, char* argv[]) { } // Set undefined command line parameters to default values - if (param_file_name == nullptr) { - param_file_name = new char[strlen(DEFAULT_PARAM_FILE_NAME) + 1]; - strcpy(param_file_name, DEFAULT_PARAM_FILE_NAME); + if (param_file_name.length() == 0) { + param_file_name = DEFAULT_PARAM_FILE_NAME; } }