Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
do not allocate/free radicals
authorSUTER Frederic <frederic.suter@cc.in2p3.fr>
Mon, 12 Apr 2021 13:54:53 +0000 (15:54 +0200)
committerSUTER Frederic <frederic.suter@cc.in2p3.fr>
Mon, 12 Apr 2021 13:54:53 +0000 (15:54 +0200)
src/surf/network_ns3.cpp
src/surf/sg_platf.cpp
src/surf/xml/platf_private.hpp
src/surf/xml/surfxml_sax_cb.cpp

index 6e4a467..71f8614 100644 (file)
@@ -185,7 +185,7 @@ static void clusterCreation_cb(simgrid::kernel::routing::ClusterCreationArgs con
 {
   ns3::NodeContainer Nodes;
 
-  for (int const& i : *cluster.radicals) {
+  for (int const& i : cluster.radicals) {
     // Create private link
     std::string host_id = cluster.prefix + std::to_string(i) + cluster.suffix;
     auto* src           = simgrid::s4u::Host::by_name(host_id)->get_netpoint();
index f66803e..0db180c 100644 (file)
@@ -167,7 +167,7 @@ void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster
     current_zone->set_limiter();
   }
 
-  for (int const& i : *cluster->radicals) {
+  for (int const& i : cluster->radicals) {
     std::string host_id = std::string(cluster->prefix) + std::to_string(i) + cluster->suffix;
 
     XBT_DEBUG("<host\tid=\"%s\"\tspeed=\"%f\">", host_id.c_str(), cluster->speeds.front());
@@ -248,7 +248,6 @@ void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster
   sg_platf_new_Zone_seal();
 
   simgrid::kernel::routing::on_cluster_creation(*cluster);
-  delete cluster->radicals;
 }
 
 void routing_cluster_add_backbone(simgrid::kernel::resource::LinkImpl* bb)
@@ -265,7 +264,7 @@ void routing_cluster_add_backbone(simgrid::kernel::resource::LinkImpl* bb)
 void sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* cabinet)
 {
   auto* zone = static_cast<simgrid::kernel::routing::ClusterZone*>(routing_get_current());
-  for (int const& radical : *cabinet->radicals) {
+  for (int const& radical : cabinet->radicals) {
     std::string id           = cabinet->prefix + std::to_string(radical) + cabinet->suffix;
     simgrid::s4u::Host* host = zone->create_host(id, std::vector<double>{cabinet->speed})->seal();
 
@@ -276,7 +275,6 @@ void sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* c
 
     zone->add_private_link_at(host->get_netpoint()->id(), {link_up->get_impl(), link_down->get_impl()});
   }
-  delete cabinet->radicals;
 }
 
 simgrid::kernel::resource::DiskImpl* sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk)
index 165da98..c48c9be 100644 (file)
@@ -92,7 +92,7 @@ public:
   std::string id;
   std::string prefix;
   std::string suffix;
-  std::vector<int>* radicals = nullptr;
+  std::vector<int> radicals;
   std::vector<double> speeds;
   int core_amount     = 0;
   double bw           = 0;
@@ -115,7 +115,7 @@ public:
   std::string id;
   std::string prefix;
   std::string suffix;
-  std::vector<int>* radicals;
+  std::vector<int> radicals;
   double speed;
   double bw;
   double lat;
index 1c89668..afe1337 100644 (file)
@@ -95,10 +95,8 @@ int surf_parse_get_int(const std::string& s)
 }
 
 /* Turn something like "1-4,6,9-11" into the vector {1,2,3,4,6,9,10,11} */
-static std::vector<int>* explodesRadical(const std::string& radicals)
+static void explodesRadical(const std::string& radicals, std::vector<int>* exploded)
 {
-  auto* exploded = new std::vector<int>();
-
   // Make all hosts
   std::vector<std::string> radical_elements;
   boost::split(radical_elements, radicals, boost::is_any_of(","));
@@ -121,8 +119,6 @@ static std::vector<int>* explodesRadical(const std::string& radicals)
     for (int i = start; i <= end; i++)
       exploded->push_back(i);
   }
-
-  return exploded;
 }
 
 
@@ -311,7 +307,8 @@ void ETag_surfxml_cluster(){
   cluster.id          = A_surfxml_cluster_id;
   cluster.prefix      = A_surfxml_cluster_prefix;
   cluster.suffix      = A_surfxml_cluster_suffix;
-  cluster.radicals    = explodesRadical(A_surfxml_cluster_radical);
+  explodesRadical(A_surfxml_cluster_radical, &cluster.radicals);
+
   cluster.speeds      = xbt_parse_get_all_speeds(surf_parsed_filename, surf_parse_lineno, A_surfxml_cluster_speed,
                                             "speed of cluster", cluster.id);
   cluster.core_amount = surf_parse_get_int(A_surfxml_cluster_core);
@@ -401,7 +398,7 @@ void STag_surfxml_cabinet(){
                                        cabinet.id.c_str());
   cabinet.lat = xbt_parse_get_time(surf_parsed_filename, surf_parse_lineno, A_surfxml_cabinet_lat, "lat of cabinet",
                                    cabinet.id.c_str());
-  cabinet.radicals = explodesRadical(A_surfxml_cabinet_radical);
+  explodesRadical(A_surfxml_cabinet_radical, &cabinet.radicals);
 
   sg_platf_new_cabinet(&cabinet);
 }