Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make this example valgrind-clean
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Wed, 12 Apr 2023 20:46:30 +0000 (22:46 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Wed, 12 Apr 2023 20:46:30 +0000 (22:46 +0200)
examples/cpp/dag-scheduling/s4u-dag-scheduling.cpp
src/s4u/s4u_Host.cpp

index 3feed78..ff68f38 100644 (file)
@@ -95,6 +95,7 @@ static void schedule_on(sg4::ExecPtr exec, sg4::Host* host, double busy_until =
 {
   exec->set_host(host);
   // We use the user data field to store up to when the host is busy
+  delete host->get_data<double>(); // In case we're erasing a previous value
   host->set_data(new double(busy_until));
   // we can also set the destination of all the input comms of this exec
   for (const auto& pred : exec->get_dependencies()) {
@@ -191,6 +192,10 @@ int main(int argc, char** argv)
     e.run();
   }
 
+  /* Cleanup memory */
+  for (auto const& host : e.get_all_hosts())
+    delete host->get_data<double>();
+
   XBT_INFO("Simulation Time: %f", simgrid_get_clock());
 
   return 0;
index f7590a0..7aa931a 100644 (file)
@@ -168,7 +168,7 @@ std::pair<std::vector<Link*>, double> Host::route_to(const Host* dest) const
 {
   std::vector<kernel::resource::StandardLinkImpl*> linkImpls;
   std::vector<Link*> links;
-  double latency;
+  double latency = 0;
   this->route_to(dest, linkImpls, &latency);
   for (auto* l : linkImpls)
     links.push_back(l->get_iface());