From cf3b6cdf6aafe4ab76056db11480371017ced47f Mon Sep 17 00:00:00 2001
From: David Parsons <david.parsons@inria.fr>
Date: Fri, 15 Dec 2023 15:01:47 +0100
Subject: [PATCH] make chromosome_file_name a string

---
 src/aevol_create.cpp | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/aevol_create.cpp b/src/aevol_create.cpp
index 952f00806..866430b40 100644
--- a/src/aevol_create.cpp
+++ b/src/aevol_create.cpp
@@ -58,7 +58,7 @@ void interpret_cmd_line_options(int argc, char* argv[]);
 
 // Command-line option variables
 static char* param_file_name = nullptr;
-static char* chromosome_file_name = nullptr;
+static std::string chromosome_file_name;
 
 int main(int argc, char* argv[]) {
   interpret_cmd_line_options(argc, argv);
@@ -76,7 +76,7 @@ int main(int argc, char* argv[]) {
   // Initialize the simulation from the parameter file
   std::list<std::string> chromosomes;
 
-  if (chromosome_file_name != nullptr) {
+  if (chromosome_file_name.length() != 0) {
     std::ifstream chromosome_file(chromosome_file_name);
     if (not chromosome_file) {
       Utils::ExitWithUsrMsg(std::string("failed to open source chromosome file ") + chromosome_file_name);
@@ -91,7 +91,6 @@ int main(int argc, char* argv[]) {
 
     std::cout << "Loading chromosome from text file " << chromosome_file_name << " (" << chromosomes.front().length()
               << " base pairs)" << std::endl;
-    delete [] chromosome_file_name;
   }
 
   if(param_file_name != nullptr) {
@@ -182,8 +181,7 @@ void interpret_cmd_line_options(int argc, char* argv[]) {
         break;
       }
       case 'C': {
-        chromosome_file_name = new char[strlen(optarg) + 1];
-        strcpy(chromosome_file_name, optarg);
+        chromosome_file_name = optarg;
         break;
       }
       default : {
-- 
GitLab