Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Get rid of MC_comm_pattern_free()
[simgrid.git] / src / mc / CommunicationDeterminismChecker.cpp
index 4c51b1b..f016a55 100644 (file)
@@ -163,7 +163,7 @@ static void deterministic_comm_pattern(int process, mc_comm_pattern_t comm, int
     }
   }
 
-  MC_comm_pattern_free(comm);
+  delete comm;
 
 }
 
@@ -323,12 +323,9 @@ std::vector<std::string> CommunicationDeterminismChecker::getTextualTrace() // o
   for (auto const& state : stack_) {
     int value;
     smx_simcall_t req = MC_state_get_executed_request(state.get(), &value);
-    if (req) {
-      char* req_str = simgrid::mc::request_to_string(
-        req, value, simgrid::mc::RequestType::executed);
-      trace.push_back(req_str);
-      xbt_free(req_str);
-    }
+    if (req)
+      trace.push_back(simgrid::mc::request_to_string(
+        req, value, simgrid::mc::RequestType::executed));
   }
   return trace;
 }
@@ -343,7 +340,7 @@ void CommunicationDeterminismChecker::prepare()
   initial_communications_pattern = xbt_dynar_new(sizeof(mc_list_comm_pattern_t), MC_list_comm_pattern_free_voidp);
   for (i=0; i < maxpid; i++){
     mc_list_comm_pattern_t process_list_pattern = xbt_new0(s_mc_list_comm_pattern_t, 1);
-    process_list_pattern->list = xbt_dynar_new(sizeof(mc_comm_pattern_t), MC_comm_pattern_free_voidp);
+    process_list_pattern->list = simgrid::xbt::newDeleteDynar<s_mc_comm_pattern_t>();
     process_list_pattern->index_comm = 0;
     xbt_dynar_insert_at(initial_communications_pattern, i, &process_list_pattern);
   }
@@ -387,8 +384,6 @@ bool all_communications_are_finished()
 
 int CommunicationDeterminismChecker::main(void)
 {
-
-  char *req_str = nullptr;
   int value;
   std::unique_ptr<simgrid::mc::VisitedState> visited_state = nullptr;
   smx_simcall_t req = nullptr;
@@ -410,10 +405,11 @@ int CommunicationDeterminismChecker::main(void)
         && (req = MC_state_get_request(state, &value))
         && (visited_state == nullptr)) {
 
-      req_str = simgrid::mc::request_to_string(req, value, simgrid::mc::RequestType::simix);
-      XBT_DEBUG("Execute: %s", req_str);
-      xbt_free(req_str);
+      XBT_DEBUG("Execute: %s",
+        simgrid::mc::request_to_string(
+          req, value, simgrid::mc::RequestType::simix).c_str());
 
+      std::string req_str;
       if (dot_output != nullptr)
         req_str = simgrid::mc::request_get_dot_output(req, value);
 
@@ -456,17 +452,15 @@ int CommunicationDeterminismChecker::main(void)
             MC_state_interleave_process(next_state.get(), &p.copy);
 
         if (dot_output != nullptr)
-          fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", state->num,  next_state->num, req_str);
+          fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n",
+            state->num,  next_state->num, req_str.c_str());
 
       } else if (dot_output != nullptr)
         fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n",
-          state->num, visited_state->other_num == -1 ? visited_state->num : visited_state->other_num, req_str);
+          state->num, visited_state->other_num == -1 ? visited_state->num : visited_state->other_num, req_str.c_str());
 
       stack_.push_back(std::move(next_state));
 
-      if (dot_output != nullptr)
-        xbt_free(req_str);
-
     } else {
 
       if (stack_.size() > (std::size_t) _sg_mc_max_depth)
@@ -526,10 +520,6 @@ int CommunicationDeterminismChecker::run()
   XBT_INFO("Check communication determinism");
   mc_model_checker->wait_for_requests();
 
-  if (mc_mode == MC_MODE_CLIENT)
-    // This will move somehwere else:
-    simgrid::mc::Client::get()->handleMessages();
-
   this->prepare();
 
   initial_global_state = std::unique_ptr<s_mc_global_t>(new s_mc_global_t());