From: Martin Quinson Date: Wed, 12 Apr 2023 20:46:30 +0000 (+0200) Subject: Make this example valgrind-clean X-Git-Tag: v3.34~165 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/c48aa279ef3e115193ed0ace973d3d9ffc18af6a Make this example valgrind-clean --- diff --git a/examples/cpp/dag-scheduling/s4u-dag-scheduling.cpp b/examples/cpp/dag-scheduling/s4u-dag-scheduling.cpp index 3feed784db..ff68f381af 100644 --- a/examples/cpp/dag-scheduling/s4u-dag-scheduling.cpp +++ b/examples/cpp/dag-scheduling/s4u-dag-scheduling.cpp @@ -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(); // 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(); + XBT_INFO("Simulation Time: %f", simgrid_get_clock()); return 0; diff --git a/src/s4u/s4u_Host.cpp b/src/s4u/s4u_Host.cpp index f7590a0199..7aa931a0f3 100644 --- a/src/s4u/s4u_Host.cpp +++ b/src/s4u/s4u_Host.cpp @@ -168,7 +168,7 @@ std::pair, double> Host::route_to(const Host* dest) const { std::vector linkImpls; std::vector links; - double latency; + double latency = 0; this->route_to(dest, linkImpls, &latency); for (auto* l : linkImpls) links.push_back(l->get_iface());