Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use std::string for Synchro instead of char*
authorGabriel Corona <gabriel.corona@loria.fr>
Mon, 30 May 2016 12:31:43 +0000 (14:31 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Mon, 30 May 2016 12:46:06 +0000 (14:46 +0200)
src/simix/Synchro.cpp
src/simix/Synchro.h
src/simix/SynchroExec.cpp
src/simix/smx_global.cpp
src/simix/smx_host.cpp
src/simix/smx_io.cpp
src/simix/smx_process.cpp
src/simix/smx_synchro.cpp

index 9d94aba..db8d8d6 100644 (file)
@@ -9,9 +9,9 @@ simgrid::simix::Synchro::Synchro() {
   simcalls = xbt_fifo_new();
 }
 
-simgrid::simix::Synchro::~Synchro() {
+simgrid::simix::Synchro::~Synchro()
+{
   xbt_fifo_free(simcalls);
-  xbt_free(name);
 }
 
 void simgrid::simix::Synchro::ref()
index b9720fe..1d7e83e 100644 (file)
@@ -6,6 +6,8 @@
 #ifndef _SIMIX_SYNCHRO_HPP
 #define _SIMIX_SYNCHRO_HPP
 
+#include <string>
+
 #include <xbt/base.h>
 #include "simgrid/forward.h"
 
@@ -21,7 +23,7 @@ namespace simix {
     Synchro();
     virtual ~Synchro();
     e_smx_state_t state;               /* State of the synchro */
-    char *name = nullptr;              /* synchro name if any */
+    std::string name;                  /* synchro name if any */
     xbt_fifo_t simcalls;               /* List of simcalls waiting for this synchro */
     char *category = nullptr;          /* For instrumentation */
 
index ddd7fc9..31d8dd4 100644 (file)
@@ -9,10 +9,11 @@
 
 simgrid::simix::Exec::Exec(const char*name, sg_host_t hostarg)
 {
-  name = xbt_strdup(name);
-  state = SIMIX_RUNNING;
-  host = hostarg;
+  this->name = name;
+  this->state = SIMIX_RUNNING;
+  this->host = hostarg;
 }
+
 simgrid::simix::Exec::~Exec()
 {
   if (surf_exec)
index 7431e34..9ba653b 100644 (file)
@@ -650,7 +650,7 @@ void SIMIX_display_process_status(void)
       XBT_INFO("Process %lu (%s@%s): waiting for %s synchro %p (%s) in state %d to finish",
           process->pid, process->name.c_str(), sg_host_get_name(process->host),
           synchro_description, process->waiting_synchro,
-          process->waiting_synchro->name, (int)process->waiting_synchro->state);
+          process->waiting_synchro->name.c_str(), (int)process->waiting_synchro->state);
     }
     else {
       XBT_INFO("Process %lu (%s@%s)", process->pid, process->name.c_str(), sg_host_get_name(process->host));
index d1d5ddb..fee9062 100644 (file)
@@ -240,7 +240,7 @@ smx_synchro_t SIMIX_execution_start(smx_process_t issuer, const char *name,
     }
   }
 
-  XBT_DEBUG("Create execute synchro %p: %s", exec, exec->name);
+  XBT_DEBUG("Create execute synchro %p: %s", exec, exec->name.c_str());
 
   return exec;
 }
index 0834120..c465d62 100644 (file)
@@ -66,7 +66,6 @@ smx_synchro_t SIMIX_file_read(smx_file_t fd, sg_size_t size, sg_host_t host)
 
 
   simgrid::simix::Io *synchro = new simgrid::simix::Io();
-  synchro->name = NULL;
   synchro->host = host;
   synchro->surf_io = surf_host_read(host, fd->surf_file, size);
 
@@ -90,7 +89,6 @@ smx_synchro_t SIMIX_file_write(smx_file_t fd, sg_size_t size, sg_host_t host)
     THROWF(host_error, 0, "Host %s failed, you cannot call this function", sg_host_get_name(host));
 
   simgrid::simix::Io *synchro = new simgrid::simix::Io();
-  synchro->name = NULL;
   synchro->host = host;
   synchro->surf_io = surf_host_write(host, fd->surf_file, size);
   synchro->surf_io->setData(synchro);
@@ -113,7 +111,6 @@ smx_synchro_t SIMIX_file_open(const char* fullpath, sg_host_t host)
     THROWF(host_error, 0, "Host %s failed, you cannot call this function", sg_host_get_name(host));
 
   simgrid::simix::Io *synchro = new simgrid::simix::Io();
-  synchro->name = NULL;
   synchro->host = host;
   synchro->surf_io = surf_host_open(host, fullpath);
   synchro->surf_io->setData(synchro);
@@ -136,7 +133,6 @@ smx_synchro_t SIMIX_file_close(smx_file_t fd, sg_host_t host)
     THROWF(host_error, 0, "Host %s failed, you cannot call this function", sg_host_get_name(host));
 
   simgrid::simix::Io *synchro = new simgrid::simix::Io();
-  synchro->name = NULL;
   synchro->host = host;
   synchro->surf_io = surf_host_close(host, fd->surf_file);
   synchro->surf_io->setData(synchro);
index 7243535..35e783c 100644 (file)
@@ -800,8 +800,6 @@ smx_synchro_t SIMIX_process_sleep(smx_process_t process, double duration)
     THROWF(host_error, 0, "Host %s failed, you cannot call this function", sg_host_get_name(host));
 
   simgrid::simix::Sleep *synchro = new simgrid::simix::Sleep();
-  synchro->name = NULL;
-
   synchro->host = host;
   synchro->surf_sleep = surf_host_sleep(host, duration);
   synchro->surf_sleep->setData(synchro);
index e82964e..67e4eaa 100644 (file)
@@ -26,7 +26,6 @@ static smx_synchro_t SIMIX_synchro_wait(sg_host_t smx_host, double timeout)
   XBT_IN("(%p, %f)",smx_host,timeout);
 
   simgrid::simix::Raw *sync = new simgrid::simix::Raw();
-  sync->name = nullptr;
   sync->sleep = surf_host_sleep(smx_host, timeout);
   sync->sleep->setData(sync);
   XBT_OUT();