Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Use RAII std::vector for s_mc_comm_pattern::data
[simgrid.git] / src / mc / mc_comm_pattern.cpp
index 4dc30b9..515a380 100644 (file)
@@ -22,25 +22,14 @@ extern "C" {
 
 mc_comm_pattern_t MC_comm_pattern_dup(mc_comm_pattern_t comm)
 {
-  mc_comm_pattern_t res = xbt_new0(s_mc_comm_pattern_t, 1);
+  mc_comm_pattern_t res = new s_mc_comm_pattern_t();
   res->index = comm->index;
   res->type = comm->type;
   res->comm_addr = comm->comm_addr;
-  res->rdv = xbt_strdup(comm->rdv);
-  res->data_size = -1;
-  res->data = nullptr;
-  if (comm->type == SIMIX_COMM_SEND) {
-    res->src_proc = comm->src_proc;
-    res->src_host = comm->src_host;
-    if (comm->data != nullptr) {
-      res->data_size = comm->data_size;
-      res->data = xbt_malloc0(comm->data_size);
-      memcpy(res->data, comm->data, comm->data_size);
-    }
-  } else {
-    res->dst_proc = comm->dst_proc;
-    res->dst_host = comm->dst_host;
-  }
+  res->rdv = comm->rdv;
+  res->data = comm->data;
+  res->dst_proc = comm->dst_proc;
+  res->dst_host = comm->dst_host;
   return res;
 }
 
@@ -138,10 +127,8 @@ void MC_handle_comm_pattern(
 }
 
 void MC_comm_pattern_free(mc_comm_pattern_t p)
-{
-  xbt_free(p->rdv);
-  xbt_free(p->data);
-  xbt_free(p);
+{  
+  delete p;
   p = nullptr;
 }