Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use plain vectors and references for link lists.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 8 Nov 2017 16:02:25 +0000 (17:02 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 8 Nov 2017 16:36:22 +0000 (17:36 +0100)
25 files changed:
examples/simdag/test/sd_test.cpp
include/simgrid/s4u/Host.hpp
include/simgrid/s4u/NetZone.hpp
src/bindings/lua/lua_platf.cpp
src/instr/instr_interface.cpp
src/kernel/routing/ClusterZone.cpp
src/kernel/routing/DijkstraZone.cpp
src/kernel/routing/DragonflyZone.cpp
src/kernel/routing/FatTreeZone.cpp
src/kernel/routing/FloydZone.cpp
src/kernel/routing/FullZone.cpp
src/kernel/routing/NetZoneImpl.cpp
src/kernel/routing/NetZoneImpl.hpp
src/kernel/routing/RoutedZone.cpp
src/kernel/routing/TorusZone.cpp
src/kernel/routing/VivaldiZone.cpp
src/s4u/s4u_host.cpp
src/s4u/s4u_netzone.cpp
src/simgrid/host.cpp
src/surf/network_cm02.cpp
src/surf/network_ns3.cpp
src/surf/ptask_L07.cpp
src/surf/xml/platf_private.hpp
src/surf/xml/surfxml_sax_cb.cpp
teshsuite/simdag/flatifier/flatifier.cpp

index f5fad58..affd7b6 100644 (file)
@@ -40,7 +40,7 @@ int main(int argc, char **argv)
   XBT_INFO("Route between %s and %s:", h1->getCname(), h2->getCname());
   std::vector<sg_link_t> route;
   double latency = 0;
-  h1->routeTo(h2, &route, &latency);
+  h1->routeTo(h2, route, &latency);
 
   for (auto const& link : route)
     XBT_INFO("   Link %s: latency = %f, bandwidth = %f", sg_link_name(link), sg_link_latency(link),
index 6495cf5..6913403 100644 (file)
@@ -104,8 +104,8 @@ public:
    */
   std::unordered_map<std::string, Storage*> const& getMountedStorages();
 
-  void routeTo(Host * dest, std::vector<Link*> * links, double* latency);
-  void routeTo(Host * dest, std::vector<surf::LinkImpl*> * links, double* latency);
+  void routeTo(Host* dest, std::vector<Link*>& links, double* latency);
+  void routeTo(Host* dest, std::vector<surf::LinkImpl*>& links, double* latency);
 
   /** Block the calling actor on an execution located on the called host
    *
index fc8c8fa..8e7429c 100644 (file)
@@ -68,7 +68,7 @@ public:
   /*** Called on each newly created regular route (not on bypass routes) */
   static simgrid::xbt::signal<void(bool symmetrical, kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
                                    kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
-                                   std::vector<surf::LinkImpl*>* link_list)>
+                                   std::vector<surf::LinkImpl*>& link_list)>
       onRouteCreation;
   static simgrid::xbt::signal<void(NetZone&)> onCreation;
   static simgrid::xbt::signal<void(NetZone&)> onSeal;
index 471e322..2fbc75e 100644 (file)
@@ -327,19 +327,18 @@ int console_add_route(lua_State *L) {
   type = lua_gettable(L,-2);
   lua_ensure(type == LUA_TSTRING,
       "Attribute 'links' must be specified for any route and must be a string (different links separated by commas or single spaces.");
-  route.link_list   = new std::vector<simgrid::surf::LinkImpl*>();
   std::vector<std::string> names;
   const char* str = lua_tostring(L, -1);
   boost::split(names, str, boost::is_any_of(", \t\r\n"));
   if (names.empty()) {
     /* unique name */
-    route.link_list->push_back(simgrid::surf::LinkImpl::byName(lua_tostring(L, -1)));
+    route.link_list.push_back(simgrid::surf::LinkImpl::byName(lua_tostring(L, -1)));
   } else {
     // Several names separated by , \t\r\n
     for (auto const& name : names) {
       if (name.length() > 0) {
         simgrid::surf::LinkImpl* link = simgrid::surf::LinkImpl::byName(name);
-        route.link_list->push_back(link);
+        route.link_list.push_back(link);
       }
     }
   }
@@ -369,7 +368,6 @@ int console_add_route(lua_State *L) {
   route.gw_dst = nullptr;
 
   sg_platf_new_route(&route);
-  delete route.link_list;
 
   return 0;
 }
@@ -407,19 +405,18 @@ int console_add_ASroute(lua_State *L) {
 
   lua_pushstring(L,"links");
   lua_gettable(L,-2);
-  ASroute.link_list = new std::vector<simgrid::surf::LinkImpl*>();
   std::vector<std::string> names;
   const char* str = lua_tostring(L, -1);
   boost::split(names, str, boost::is_any_of(", \t\r\n"));
   if (names.empty()) {
     /* unique name with no comma */
-    ASroute.link_list->push_back(simgrid::surf::LinkImpl::byName(lua_tostring(L, -1)));
+    ASroute.link_list.push_back(simgrid::surf::LinkImpl::byName(lua_tostring(L, -1)));
   } else {
     // Several names separated by , \t\r\n
     for (auto const& name : names) {
       if (name.length() > 0) {
         simgrid::surf::LinkImpl* link = simgrid::surf::LinkImpl::byName(name);
-        ASroute.link_list->push_back(link);
+        ASroute.link_list.push_back(link);
       }
     }
   }
@@ -440,7 +437,6 @@ int console_add_ASroute(lua_State *L) {
   lua_pop(L,1);
 
   sg_platf_new_route(&ASroute);
-  delete ASroute.link_list;
 
   return 0;
 }
index 8053955..455dffe 100644 (file)
@@ -307,7 +307,7 @@ static void instr_user_srcdst_variable(double time, const char *src, const char
     xbt_die("Element '%s' not found!",dst);
 
   std::vector<simgrid::surf::LinkImpl*> route;
-  simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(src_elm, dst_elm, &route, nullptr);
+  simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(src_elm, dst_elm, route, nullptr);
   for (auto const& link : route)
     instr_user_variable(time, link->getCname(), variable, father_type, value, what, nullptr, &user_link_variables);
 }
index 08da44b..131fe93 100644 (file)
@@ -30,7 +30,7 @@ void ClusterZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cba
     xbt_assert(not src->isRouter(), "Routing from a cluster private router to itself is meaningless");
 
     std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePosition(src->id()));
-    route->link_list->push_back(info.first);
+    route->link_list.push_back(info.first);
     if (lat)
       *lat += info.first->latency();
     return;
@@ -39,19 +39,19 @@ void ClusterZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cba
   if (not src->isRouter()) { // No private link for the private router
     if (hasLimiter_) { // limiter for sender
       std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePositionWithLoopback(src->id()));
-      route->link_list->push_back(info.first);
+      route->link_list.push_back(info.first);
     }
 
     std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePositionWithLimiter(src->id()));
     if (info.first) { // link up
-      route->link_list->push_back(info.first);
+      route->link_list.push_back(info.first);
       if (lat)
         *lat += info.first->latency();
     }
   }
 
   if (backbone_) {
-    route->link_list->push_back(backbone_);
+    route->link_list.push_back(backbone_);
     if (lat)
       *lat += backbone_->latency();
   }
@@ -60,13 +60,13 @@ void ClusterZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cba
 
     std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePositionWithLimiter(dst->id()));
     if (info.second) { // link down
-      route->link_list->push_back(info.second);
+      route->link_list.push_back(info.second);
       if (lat)
         *lat += info.second->latency();
     }
     if (hasLimiter_) { // limiter for receiver
       info = privateLinks_.at(nodePositionWithLoopback(dst->id()));
-      route->link_list->push_back(info.first);
+      route->link_list.push_back(info.first);
     }
   }
 }
index 7178900..85dfd1a 100644 (file)
@@ -21,13 +21,10 @@ static void graph_node_data_free(void* n)
   delete data;
 }
 
-static void graph_edge_data_free(void* e) // FIXME: useless code duplication
+static void graph_edge_data_free(void* e)
 {
   sg_platf_route_cbarg_t e_route = static_cast<sg_platf_route_cbarg_t>(e);
-  if (e_route) {
-    delete e_route->link_list;
-    delete e_route;
-  }
+  delete e_route;
 }
 
 /* Utility functions */
@@ -60,8 +57,7 @@ void DijkstraZone::seal()
 
       if (not found) {
         sg_platf_route_cbarg_t e_route = new s_sg_platf_route_cbarg_t;
-        e_route->link_list             = new std::vector<surf::LinkImpl*>();
-        e_route->link_list->push_back(surf_network_model->loopback_);
+        e_route->link_list.push_back(surf_network_model->loopback_);
         xbt_graph_new_edge(routeGraph_, node, node, e_route);
       }
     }
@@ -155,8 +151,8 @@ void DijkstraZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cb
 
     sg_platf_route_cbarg_t e_route = static_cast<sg_platf_route_cbarg_t>(xbt_graph_edge_get_data(edge));
 
-    for (auto const& link : *e_route->link_list) {
-      route->link_list->insert(route->link_list->begin(), link);
+    for (auto const& link : e_route->link_list) {
+      route->link_list.insert(route->link_list.begin(), link);
       if (lat)
         *lat += static_cast<surf::LinkImpl*>(link)->latency();
     }
@@ -199,7 +195,7 @@ void DijkstraZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cb
         graph_node_data_t data             = static_cast<graph_node_data_t>(xbt_graph_node_get_data(u_node));
         int u_id                           = data->graph_id;
         sg_platf_route_cbarg_t tmp_e_route = static_cast<sg_platf_route_cbarg_t>(xbt_graph_edge_get_data(edge));
-        int cost_v_u                       = tmp_e_route->link_list->size(); /* count of links, old model assume 1 */
+        int cost_v_u                       = tmp_e_route->link_list.size(); /* count of links, old model assume 1 */
 
         if (cost_v_u + cost_arr[v_id] < cost_arr[u_id]) {
           pred_arr[u_id] = v_id;
@@ -237,18 +233,18 @@ void DijkstraZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cb
 
       NetPoint* gw_dst_net_elm      = nullptr;
       NetPoint* prev_gw_src_net_elm = nullptr;
-      getGlobalRoute(gw_dst_net_elm, prev_gw_src_net_elm, &e_route_as_to_as, nullptr);
-      auto pos = route->link_list->begin();
+      getGlobalRoute(gw_dst_net_elm, prev_gw_src_net_elm, e_route_as_to_as, nullptr);
+      auto pos = route->link_list.begin();
       for (auto const& link : e_route_as_to_as) {
-        route->link_list->insert(pos, link);
+        route->link_list.insert(pos, link);
         if (lat)
           *lat += link->latency();
         pos++;
       }
     }
 
-    for (auto const& link : *e_route->link_list) {
-      route->link_list->insert(route->link_list->begin(), link);
+    for (auto const& link : e_route->link_list) {
+      route->link_list.insert(route->link_list.begin(), link);
       if (lat)
         *lat += static_cast<surf::LinkImpl*>(link)->latency();
     }
index 429a863..d6eecc5 100644 (file)
@@ -273,7 +273,7 @@ void DragonflyZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_c
   if ((src->id() == dst->id()) && hasLoopback_) {
     std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePosition(src->id()));
 
-    route->link_list->push_back(info.first);
+    route->link_list.push_back(info.first);
     if (latency)
       *latency += info.first->latency();
     return;
@@ -294,13 +294,13 @@ void DragonflyZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_c
   DragonflyRouter* currentRouter = myRouter;
 
   // node->router local link
-  route->link_list->push_back(myRouter->myNodes_[myCoords[3] * numLinksperLink_]);
+  route->link_list.push_back(myRouter->myNodes_[myCoords[3] * numLinksperLink_]);
   if (latency)
     *latency += myRouter->myNodes_[myCoords[3] * numLinksperLink_]->latency();
 
   if (hasLimiter_) { // limiter for sender
     std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePositionWithLoopback(src->id()));
-    route->link_list->push_back(info.first);
+    route->link_list.push_back(info.first);
   }
 
   if (targetRouter != myRouter) {
@@ -310,7 +310,7 @@ void DragonflyZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_c
       // go to the router of our group connected to this one.
       if (currentRouter->blade_ != targetCoords[0]) {
         // go to the nth router in our chassis
-        route->link_list->push_back(currentRouter->greenLinks_[targetCoords[0]]);
+        route->link_list.push_back(currentRouter->greenLinks_[targetCoords[0]]);
         if (latency)
           *latency += currentRouter->greenLinks_[targetCoords[0]]->latency();
         currentRouter = routers_[myCoords[0] * (numChassisPerGroup_ * numBladesPerChassis_) +
@@ -319,14 +319,14 @@ void DragonflyZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_c
 
       if (currentRouter->chassis_ != 0) {
         // go to the first chassis of our group
-        route->link_list->push_back(currentRouter->blackLinks_[0]);
+        route->link_list.push_back(currentRouter->blackLinks_[0]);
         if (latency)
           *latency += currentRouter->blackLinks_[0]->latency();
         currentRouter = routers_[myCoords[0] * (numChassisPerGroup_ * numBladesPerChassis_) + targetCoords[0]];
       }
 
       // go to destination group - the only optical hop
-      route->link_list->push_back(currentRouter->blueLinks_[0]);
+      route->link_list.push_back(currentRouter->blueLinks_[0]);
       if (latency)
         *latency += currentRouter->blueLinks_[0]->latency();
       currentRouter = routers_[targetCoords[0] * (numChassisPerGroup_ * numBladesPerChassis_) + myCoords[0]];
@@ -334,7 +334,7 @@ void DragonflyZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_c
 
     // same group, but same blade ?
     if (targetRouter->blade_ != currentRouter->blade_) {
-      route->link_list->push_back(currentRouter->greenLinks_[targetCoords[2]]);
+      route->link_list.push_back(currentRouter->greenLinks_[targetCoords[2]]);
       if (latency)
         *latency += currentRouter->greenLinks_[targetCoords[2]]->latency();
       currentRouter = routers_[targetCoords[0] * (numChassisPerGroup_ * numBladesPerChassis_) + targetCoords[2]];
@@ -342,7 +342,7 @@ void DragonflyZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_c
 
     // same blade, but same chassis ?
     if (targetRouter->chassis_ != currentRouter->chassis_) {
-      route->link_list->push_back(currentRouter->blackLinks_[targetCoords[1]]);
+      route->link_list.push_back(currentRouter->blackLinks_[targetCoords[1]]);
       if (latency)
         *latency += currentRouter->blackLinks_[targetCoords[1]]->latency();
     }
@@ -350,11 +350,11 @@ void DragonflyZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_c
 
   if (hasLimiter_) { // limiter for receiver
     std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePositionWithLoopback(dst->id()));
-    route->link_list->push_back(info.first);
+    route->link_list.push_back(info.first);
   }
 
   // router->node local link
-  route->link_list->push_back(targetRouter->myNodes_[targetCoords[3] * numLinksperLink_ + numLinksperLink_ - 1]);
+  route->link_list.push_back(targetRouter->myNodes_[targetCoords[3] * numLinksperLink_ + numLinksperLink_ - 1]);
   if (latency)
     *latency += targetRouter->myNodes_[targetCoords[3] * numLinksperLink_ + numLinksperLink_ - 1]->latency();
 }
index 92301b4..16e2798 100644 (file)
@@ -78,7 +78,7 @@ void FatTreeZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cba
 
   /* In case destination is the source, and there is a loopback, let's use it instead of going up to a switch */
   if (source->id == destination->id && this->hasLoopback_) {
-    into->link_list->push_back(source->loopback);
+    into->link_list.push_back(source->loopback);
     if (latency)
       *latency += source->loopback->latency();
     return;
@@ -95,13 +95,13 @@ void FatTreeZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cba
 
     int k = this->upperLevelNodesNumber_[currentNode->level];
     d     = d % k;
-    into->link_list->push_back(currentNode->parents[d]->upLink);
+    into->link_list.push_back(currentNode->parents[d]->upLink);
 
     if (latency)
       *latency += currentNode->parents[d]->upLink->latency();
 
     if (this->hasLimiter_)
-      into->link_list->push_back(currentNode->limiterLink);
+      into->link_list.push_back(currentNode->limiterLink);
     currentNode = currentNode->parents[d]->upNode;
   }
 
@@ -112,12 +112,12 @@ void FatTreeZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cba
   while (currentNode != destination) {
     for (unsigned int i = 0; i < currentNode->children.size(); i++) {
       if (i % this->lowerLevelNodesNumber_[currentNode->level - 1] == destination->label[currentNode->level - 1]) {
-        into->link_list->push_back(currentNode->children[i]->downLink);
+        into->link_list.push_back(currentNode->children[i]->downLink);
         if (latency)
           *latency += currentNode->children[i]->downLink->latency();
         currentNode = currentNode->children[i]->downNode;
         if (this->hasLimiter_)
-          into->link_list->push_back(currentNode->limiterLink);
+          into->link_list.push_back(currentNode->limiterLink);
         XBT_DEBUG("%d(%u,%u) is accessible through %d(%u,%u)", destination->id, destination->level,
                   destination->position, currentNode->id, currentNode->level, currentNode->position);
       }
index 4162fa4..354f13d 100644 (file)
@@ -36,7 +36,7 @@ FloydZone::~FloydZone()
   /* Delete link_table */
   for (unsigned int i = 0; i < table_size; i++)
     for (unsigned int j = 0; j < table_size; j++)
-      routing_route_free(TO_FLOYD_LINK(i, j));
+      delete TO_FLOYD_LINK(i, j);
   delete[] linkTable_;
 
   delete[] predecessorTable_;
@@ -74,8 +74,8 @@ void FloydZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg
       getGlobalRoute(prev_dst_gw, e_route->gw_src, route->link_list, lat);
     }
 
-    for (auto const& link : *e_route->link_list) {
-      route->link_list->push_back(link);
+    for (auto const& link : e_route->link_list) {
+      route->link_list.push_back(link);
       if (lat)
         *lat += link->latency();
     }
@@ -119,7 +119,7 @@ void FloydZone::addRoute(sg_platf_route_cbarg_t route)
   TO_FLOYD_LINK(route->src->id(), route->dst->id()) = newExtendedRoute(hierarchy_, route, 1);
   TO_FLOYD_PRED(route->src->id(), route->dst->id()) = route->src->id();
   TO_FLOYD_COST(route->src->id(), route->dst->id()) =
-      (TO_FLOYD_LINK(route->src->id(), route->dst->id()))->link_list->size();
+      (TO_FLOYD_LINK(route->src->id(), route->dst->id()))->link_list.size();
 
   if (route->symmetrical == true) {
     if (route->gw_dst) // netzone route (to adapt the error message, if any)
@@ -147,7 +147,7 @@ void FloydZone::addRoute(sg_platf_route_cbarg_t route)
     TO_FLOYD_LINK(route->dst->id(), route->src->id()) = newExtendedRoute(hierarchy_, route, 0);
     TO_FLOYD_PRED(route->dst->id(), route->src->id()) = route->dst->id();
     TO_FLOYD_COST(route->dst->id(), route->src->id()) =
-        (TO_FLOYD_LINK(route->dst->id(), route->src->id()))->link_list->size(); /* count of links, old model assume 1 */
+        (TO_FLOYD_LINK(route->dst->id(), route->src->id()))->link_list.size(); /* count of links, old model assume 1 */
   }
 }
 
@@ -179,8 +179,7 @@ void FloydZone::seal()
         e_route            = new s_sg_platf_route_cbarg_t;
         e_route->gw_src    = nullptr;
         e_route->gw_dst    = nullptr;
-        e_route->link_list = new std::vector<surf::LinkImpl*>();
-        e_route->link_list->push_back(surf_network_model->loopback_);
+        e_route->link_list.push_back(surf_network_model->loopback_);
         TO_FLOYD_LINK(i, i) = e_route;
         TO_FLOYD_PRED(i, i) = i;
         TO_FLOYD_COST(i, i) = 1;
index d6e4660..a05458a 100644 (file)
@@ -34,8 +34,7 @@ void FullZone::seal()
         e_route            = new s_sg_platf_route_cbarg_t;
         e_route->gw_src    = nullptr;
         e_route->gw_dst    = nullptr;
-        e_route->link_list = new std::vector<surf::LinkImpl*>();
-        e_route->link_list->push_back(surf_network_model->loopback_);
+        e_route->link_list.push_back(surf_network_model->loopback_);
         TO_ROUTE_FULL(i, i) = e_route;
       }
     }
@@ -48,12 +47,8 @@ FullZone::~FullZone()
     unsigned int table_size = getTableSize();
     /* Delete routing table */
     for (unsigned int i = 0; i < table_size; i++)
-      for (unsigned int j = 0; j < table_size; j++) {
-        if (TO_ROUTE_FULL(i, j)) {
-          delete TO_ROUTE_FULL(i, j)->link_list;
-          delete TO_ROUTE_FULL(i, j);
-        }
-      }
+      for (unsigned int j = 0; j < table_size; j++)
+        delete TO_ROUTE_FULL(i, j);
     delete[] routingTable_;
   }
 }
@@ -68,8 +63,8 @@ void FullZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg_
   if (e_route != nullptr) {
     res->gw_src = e_route->gw_src;
     res->gw_dst = e_route->gw_dst;
-    for (auto const& link : *e_route->link_list) {
-      res->link_list->push_back(link);
+    for (auto const& link : e_route->link_list) {
+      res->link_list.push_back(link);
       if (lat)
         *lat += link->latency();
     }
index 9609323..1bccf4a 100644 (file)
@@ -70,7 +70,7 @@ void NetZoneImpl::addBypassRoute(sg_platf_route_cbarg_t e_route)
   if (e_route->gw_dst) {
     XBT_DEBUG("Load bypassNetzoneRoute from %s@%s to %s@%s", e_route->src->getCname(), e_route->gw_src->getCname(),
               e_route->dst->getCname(), e_route->gw_dst->getCname());
-    xbt_assert(not e_route->link_list->empty(), "Bypass route between %s@%s and %s@%s cannot be empty.",
+    xbt_assert(not e_route->link_list.empty(), "Bypass route between %s@%s and %s@%s cannot be empty.",
                e_route->src->getCname(), e_route->gw_src->getCname(), e_route->dst->getCname(),
                e_route->gw_dst->getCname());
     xbt_assert(bypassRoutes_.find({e_route->src, e_route->dst}) == bypassRoutes_.end(),
@@ -78,7 +78,7 @@ void NetZoneImpl::addBypassRoute(sg_platf_route_cbarg_t e_route)
                e_route->gw_src->getCname(), e_route->dst->getCname(), e_route->gw_dst->getCname());
   } else {
     XBT_DEBUG("Load bypassRoute from %s to %s", e_route->src->getCname(), e_route->dst->getCname());
-    xbt_assert(not e_route->link_list->empty(), "Bypass route between %s and %s cannot be empty.",
+    xbt_assert(not e_route->link_list.empty(), "Bypass route between %s and %s cannot be empty.",
                e_route->src->getCname(), e_route->dst->getCname());
     xbt_assert(bypassRoutes_.find({e_route->src, e_route->dst}) == bypassRoutes_.end(),
                "The bypass route between %s and %s already exists.", e_route->src->getCname(),
@@ -87,7 +87,7 @@ void NetZoneImpl::addBypassRoute(sg_platf_route_cbarg_t e_route)
 
   /* Build a copy that will be stored in the dict */
   kernel::routing::BypassRoute* newRoute = new kernel::routing::BypassRoute(e_route->gw_src, e_route->gw_dst);
-  for (auto const& link : *e_route->link_list)
+  for (auto const& link : e_route->link_list)
     newRoute->links.push_back(link);
 
   /* Store it */
@@ -205,7 +205,7 @@ static void find_common_ancestors(NetPoint* src, NetPoint* dst,
 
 /* PRECONDITION: this is the common ancestor of src and dst */
 bool NetZoneImpl::getBypassRoute(routing::NetPoint* src, routing::NetPoint* dst,
-                                 /* OUT */ std::vector<surf::LinkImpl*>* links, double* latency)
+                                 /* OUT */ std::vector<surf::LinkImpl*>& links, double* latency)
 {
   // If never set a bypass route return nullptr without any further computations
   if (bypassRoutes_.empty())
@@ -216,7 +216,7 @@ bool NetZoneImpl::getBypassRoute(routing::NetPoint* src, routing::NetPoint* dst,
     if (bypassRoutes_.find({src, dst}) != bypassRoutes_.end()) {
       BypassRoute* bypassedRoute = bypassRoutes_.at({src, dst});
       for (surf::LinkImpl* const& link : bypassedRoute->links) {
-        links->push_back(link);
+        links.push_back(link);
         if (latency)
           *latency += link->latency();
       }
@@ -300,7 +300,7 @@ bool NetZoneImpl::getBypassRoute(routing::NetPoint* src, routing::NetPoint* dst,
     if (src != key.first)
       getGlobalRoute(src, bypassedRoute->gw_src, links, latency);
     for (surf::LinkImpl* const& link : bypassedRoute->links) {
-      links->push_back(link);
+      links.push_back(link);
       if (latency)
         *latency += link->latency();
     }
@@ -313,7 +313,7 @@ bool NetZoneImpl::getBypassRoute(routing::NetPoint* src, routing::NetPoint* dst,
 }
 
 void NetZoneImpl::getGlobalRoute(routing::NetPoint* src, routing::NetPoint* dst,
-                                 /* OUT */ std::vector<surf::LinkImpl*>* links, double* latency)
+                                 /* OUT */ std::vector<surf::LinkImpl*>& links, double* latency)
 {
   s_sg_platf_route_cbarg_t route{};
 
@@ -333,15 +333,14 @@ void NetZoneImpl::getGlobalRoute(routing::NetPoint* src, routing::NetPoint* dst,
 
   /* If src and dst are in the same netzone, life is good */
   if (src_ancestor == dst_ancestor) { /* SURF_ROUTING_BASE */
-    route.link_list = links;
+    route.link_list = std::move(links);
     common_ancestor->getLocalRoute(src, dst, &route, latency);
+    links = std::move(route.link_list);
     return;
   }
 
   /* Not in the same netzone, no bypass. We'll have to find our path between the netzones recursively */
 
-  route.link_list = new std::vector<surf::LinkImpl*>();
-
   common_ancestor->getLocalRoute(src_ancestor->netpoint_, dst_ancestor->netpoint_, &route, latency);
   xbt_assert((route.gw_src != nullptr) && (route.gw_dst != nullptr), "bad gateways for route from \"%s\" to \"%s\"",
              src->getCname(), dst->getCname());
@@ -349,9 +348,8 @@ void NetZoneImpl::getGlobalRoute(routing::NetPoint* src, routing::NetPoint* dst,
   /* If source gateway is not our source, we have to recursively find our way up to this point */
   if (src != route.gw_src)
     getGlobalRoute(src, route.gw_src, links, latency);
-  for (auto const& link : *route.link_list)
-    links->push_back(link);
-  delete route.link_list;
+  for (auto const& link : route.link_list)
+    links.push_back(link);
 
   /* If dest gateway is not our destination, we have to recursively find our way from this point */
   if (route.gw_dst != dst)
index 95f5ae3..c2d7738 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016. The SimGrid Team. All rights reserved.               */
+/* Copyright (c) 2016-2017. The SimGrid Team. All rights reserved.               */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -76,7 +76,7 @@ protected:
   /** @brief retrieves the list of all routes of size 1 (of type src x dst x Link) */
   /* returns whether we found a bypass path */
   bool getBypassRoute(routing::NetPoint * src, routing::NetPoint * dst,
-                      /* OUT */ std::vector<surf::LinkImpl*> * links, double* latency);
+                      /* OUT */ std::vector<surf::LinkImpl*>& links, double* latency);
 
 public:
   /* @brief get the route between two nodes in the full platform
@@ -87,7 +87,7 @@ public:
    * @param latency Accumulator in which the latencies should be added (caller must set it to 0)
    */
   static void getGlobalRoute(routing::NetPoint * src, routing::NetPoint * dst,
-                             /* OUT */ std::vector<surf::LinkImpl*> * links, double* latency);
+                             /* OUT */ std::vector<surf::LinkImpl*>& links, double* latency);
 
   virtual void getGraph(xbt_graph_t graph, std::map<std::string, xbt_node_t> * nodes,
                         std::map<std::string, xbt_edge_t> * edges) = 0;
index 0263235..dab2e4e 100644 (file)
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_routing_generic, surf_route, "Generic implementation of the surf routing");
 
-void routing_route_free(sg_platf_route_cbarg_t route)
-{
-  if (route) {
-    delete route->link_list;
-    delete route;
-  }
-}
-
 /* ***************************************************************** */
 /* *********************** GENERIC METHODS ************************* */
 
@@ -82,7 +74,6 @@ void RoutedZone::getGraph(xbt_graph_t graph, std::map<std::string, xbt_node_t>*
         continue;
 
       sg_platf_route_cbarg_t route = new s_sg_platf_route_cbarg_t;
-      route->link_list             = new std::vector<surf::LinkImpl*>();
 
       getLocalRoute(my_src, my_dst, route, nullptr);
 
@@ -101,7 +92,7 @@ void RoutedZone::getGraph(xbt_graph_t graph, std::map<std::string, xbt_node_t>*
         previous_name = my_src->getCname();
       }
 
-      for (auto const& link : *route->link_list) {
+      for (auto const& link : route->link_list) {
         const char* link_name = link->getCname();
         current               = new_xbt_graph_node(graph, link_name, nodes);
         current_name          = link_name;
@@ -121,7 +112,6 @@ void RoutedZone::getGraph(xbt_graph_t graph, std::map<std::string, xbt_node_t>*
       new_xbt_graph_edge(graph, previous, current, edges);
       XBT_DEBUG("  %s -> %s", previous_name, current_name);
 
-      delete route->link_list;
       delete route;
     }
   }
@@ -136,7 +126,6 @@ sg_platf_route_cbarg_t RoutedZone::newExtendedRoute(RoutingMode hierarchy, sg_pl
   sg_platf_route_cbarg_t result;
 
   result            = new s_sg_platf_route_cbarg_t;
-  result->link_list = new std::vector<surf::LinkImpl*>();
 
   xbt_assert(hierarchy == RoutingMode::base || hierarchy == RoutingMode::recursive,
              "The hierarchy of this netzone is neither BASIC nor RECURSIVE, I'm lost here.");
@@ -148,13 +137,13 @@ sg_platf_route_cbarg_t RoutedZone::newExtendedRoute(RoutingMode hierarchy, sg_pl
     result->gw_dst = routearg->gw_dst;
   }
 
-  for (auto const& link : *routearg->link_list) {
+  for (auto const& link : routearg->link_list) {
     if (change_order)
-      result->link_list->push_back(link);
+      result->link_list.push_back(link);
     else
-      result->link_list->insert(result->link_list->begin(), link);
+      result->link_list.insert(result->link_list.begin(), link);
   }
-  result->link_list->shrink_to_fit();
+  result->link_list.shrink_to_fit();
 
   return result;
 }
@@ -186,7 +175,7 @@ void RoutedZone::addRouteCheckParams(sg_platf_route_cbarg_t route)
     XBT_DEBUG("Load Route from \"%s\" to \"%s\"", srcName, dstName);
     xbt_assert(src, "Cannot add a route from %s to %s: %s does not exist.", srcName, dstName, srcName);
     xbt_assert(dst, "Cannot add a route from %s to %s: %s does not exist.", srcName, dstName, dstName);
-    xbt_assert(not route->link_list->empty(), "Empty route (between %s and %s) forbidden.", srcName, dstName);
+    xbt_assert(not route->link_list.empty(), "Empty route (between %s and %s) forbidden.", srcName, dstName);
     xbt_assert(not src->isNetZone(),
                "When defining a route, src cannot be a netzone such as '%s'. Did you meant to have an NetzoneRoute?",
                srcName);
@@ -211,7 +200,7 @@ void RoutedZone::addRouteCheckParams(sg_platf_route_cbarg_t route)
                dstName, route->gw_dst->getCname(), srcName);
     xbt_assert(dst, "Cannot add a route from %s@%s to %s@%s: %s does not exist.", srcName, route->gw_src->getCname(),
                dstName, route->gw_dst->getCname(), dstName);
-    xbt_assert(not route->link_list->empty(), "Empty route (between %s@%s and %s@%s) forbidden.", srcName,
+    xbt_assert(not route->link_list.empty(), "Empty route (between %s@%s and %s@%s) forbidden.", srcName,
                route->gw_src->getCname(), dstName, route->gw_dst->getCname());
   }
 
index 4992637..1a684e7 100644 (file)
@@ -102,7 +102,7 @@ void TorusZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg
   if (src->id() == dst->id() && hasLoopback_) {
     std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(src->id() * linkCountPerNode_);
 
-    route->link_list->push_back(info.first);
+    route->link_list.push_back(info.first);
     if (lat)
       *lat += info.first->latency();
     return;
@@ -179,17 +179,17 @@ void TorusZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg
 
     if (hasLimiter_) { // limiter for sender
       info = privateLinks_.at(nodeOffset + (hasLoopback_ ? 1 : 0));
-      route->link_list->push_back(info.first);
+      route->link_list.push_back(info.first);
     }
 
     info = privateLinks_.at(linkOffset);
 
     if (use_lnk_up == false) {
-      route->link_list->push_back(info.second);
+      route->link_list.push_back(info.second);
       if (lat)
         *lat += info.second->latency();
     } else {
-      route->link_list->push_back(info.first);
+      route->link_list.push_back(info.first);
       if (lat)
         *lat += info.first->latency();
     }
index a6b4fc3..3d78b3a 100644 (file)
@@ -91,7 +91,7 @@ void VivaldiZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cba
   if (src_link != privateLinks_.end()) {
     std::pair<surf::LinkImpl*, surf::LinkImpl*> info = src_link->second;
     if (info.first) {
-      route->link_list->push_back(info.first);
+      route->link_list.push_back(info.first);
       if (lat)
         *lat += info.first->latency();
     }
@@ -103,7 +103,7 @@ void VivaldiZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cba
   if (dst_link != privateLinks_.end()) {
     std::pair<surf::LinkImpl*, surf::LinkImpl*> info = dst_link->second;
     if (info.second) {
-      route->link_list->push_back(info.second);
+      route->link_list.push_back(info.second);
       if (lat)
         *lat += info.second->latency();
     }
index b4245ed..f173821 100644 (file)
@@ -153,22 +153,22 @@ void Host::actorList(std::vector<ActorPtr>* whereto)
  * walk through the routing components tree and find a route between hosts
  * by calling each "get_route" function in each routing component.
  */
-void Host::routeTo(Host* dest, std::vector<Link*>* links, double* latency)
+void Host::routeTo(Host* dest, std::vector<Link*>& links, double* latency)
 {
   std::vector<surf::LinkImpl*> linkImpls;
-  this->routeTo(dest, &linkImpls, latency);
+  this->routeTo(dest, linkImpls, latency);
   for (surf::LinkImpl* const& l : linkImpls)
-    links->push_back(&l->piface_);
+    links.push_back(&l->piface_);
 }
 
 /** @brief Just like Host::routeTo, but filling an array of link implementations */
-void Host::routeTo(Host* dest, std::vector<surf::LinkImpl*>* links, double* latency)
+void Host::routeTo(Host* dest, std::vector<surf::LinkImpl*>& links, double* latency)
 {
   simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(pimpl_netpoint, dest->pimpl_netpoint, links, latency);
   if (XBT_LOG_ISENABLED(surf_route, xbt_log_priority_debug)) {
     XBT_CDEBUG(surf_route, "Route from '%s' to '%s' (latency: %f):", getCname(), dest->getCname(),
                (latency == nullptr ? -1 : *latency));
-    for (auto const& link : *links)
+    for (auto const& link : links)
       XBT_CDEBUG(surf_route, "Link %s", link->getCname());
   }
 }
index 2675596..52e4014 100644 (file)
@@ -18,7 +18,7 @@ namespace s4u {
 
 simgrid::xbt::signal<void(bool symmetrical, kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
                           kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
-                          std::vector<surf::LinkImpl*>* link_list)>
+                          std::vector<surf::LinkImpl*>& link_list)>
     NetZone::onRouteCreation;
 simgrid::xbt::signal<void(NetZone&)> NetZone::onCreation;
 simgrid::xbt::signal<void(NetZone&)> NetZone::onSeal;
index 5b709b4..51da4ba 100644 (file)
@@ -217,7 +217,7 @@ void sg_host_set_property_value(sg_host_t host, const char* name, const char* va
 void sg_host_route(sg_host_t from, sg_host_t to, xbt_dynar_t links)
 {
   std::vector<simgrid::s4u::Link*> vlinks;
-  from->routeTo(to, &vlinks, nullptr);
+  from->routeTo(to, vlinks, nullptr);
   for (auto const& link : vlinks)
     xbt_dynar_push(links, &link);
 }
@@ -231,7 +231,7 @@ double sg_host_route_latency(sg_host_t from, sg_host_t to)
 {
   std::vector<simgrid::s4u::Link*> vlinks;
   double res = 0;
-  from->routeTo(to, &vlinks, &res);
+  from->routeTo(to, vlinks, &res);
   return res;
 }
 /**
@@ -245,7 +245,7 @@ double sg_host_route_bandwidth(sg_host_t from, sg_host_t to)
   double min_bandwidth = -1.0;
 
   std::vector<simgrid::s4u::Link*> vlinks;
-  from->routeTo(to, &vlinks, nullptr);
+  from->routeTo(to, vlinks, nullptr);
   for (auto const& link : vlinks) {
     double bandwidth = link->bandwidth();
     if (bandwidth < min_bandwidth || min_bandwidth < 0.0)
index 3e9a0c7..3761084 100644 (file)
@@ -266,24 +266,23 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz
 {
   int failed = 0;
   double latency = 0.0;
-  std::vector<LinkImpl*>* back_route = nullptr;
-  std::vector<LinkImpl*>* route = new std::vector<LinkImpl*>();
+  std::vector<LinkImpl*> back_route;
+  std::vector<LinkImpl*> route;
 
   XBT_IN("(%s,%s,%g,%g)", src->getCname(), dst->getCname(), size, rate);
 
   src->routeTo(dst, route, &latency);
-  xbt_assert(not route->empty() || latency,
+  xbt_assert(not route.empty() || latency,
              "You're trying to send data from %s to %s but there is no connecting path between these two hosts.",
              src->getCname(), dst->getCname());
 
-  for (auto const& link : *route)
+  for (auto const& link : route)
     if (link->isOff())
       failed = 1;
 
   if (sg_network_crosstraffic == 1) {
-    back_route = new std::vector<LinkImpl*>();
     dst->routeTo(src, back_route, nullptr);
-    for (auto const& link : *back_route)
+    for (auto const& link : back_route)
       if (link->isOff())
         failed = 1;
   }
@@ -299,10 +298,10 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz
 
   double bandwidth_bound = -1.0;
   if (sg_weight_S_parameter > 0)
-    for (auto const& link : *route)
+    for (auto const& link : route)
       action->weight_ += sg_weight_S_parameter / link->bandwidth();
 
-  for (auto const& link : *route) {
+  for (auto const& link : route) {
     double bb       = bandwidthFactor(size) * link->bandwidth();
     bandwidth_bound = (bandwidth_bound < 0.0) ? bb : std::min(bandwidth_bound, bb);
   }
@@ -311,16 +310,15 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz
   action->latency_ *= latencyFactor(size);
   action->rate_ = bandwidthConstraint(action->rate_, bandwidth_bound, size);
 
-  int constraints_per_variable = route->size();
-  if (back_route != nullptr)
-    constraints_per_variable += back_route->size();
+  int constraints_per_variable = route.size();
+  constraints_per_variable += back_route.size();
 
   if (action->latency_ > 0) {
     action->setVariable(lmm_variable_new(maxminSystem_, action, 0.0, -1.0, constraints_per_variable));
     if (getUpdateMechanism() == UM_LAZY) {
       // add to the heap the event when the latency is payed
       XBT_DEBUG("Added action (%p) one latency event at date %f", action, action->latency_ + action->getLastUpdate());
-      action->heapInsert(actionHeap_, action->latency_ + action->getLastUpdate(), route->empty() ? NORMAL : LATENCY);
+      action->heapInsert(actionHeap_, action->latency_ + action->getLastUpdate(), route.empty() ? NORMAL : LATENCY);
     }
   } else
     action->setVariable(lmm_variable_new(maxminSystem_, action, 1.0, -1.0, constraints_per_variable));
@@ -331,21 +329,18 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz
     lmm_update_variable_bound(maxminSystem_, action->getVariable(), (action->latCurrent_ > 0) ? std::min(action->rate_, sg_tcp_gamma / (2.0 * action->latCurrent_)) : action->rate_);
   }
 
-  for (auto const& link : *route)
+  for (auto const& link : route)
     lmm_expand(maxminSystem_, link->constraint(), action->getVariable(), 1.0);
 
-  if (back_route != nullptr) { //  sg_network_crosstraffic was activated
+  if (not back_route.empty()) { //  sg_network_crosstraffic was activated
     XBT_DEBUG("Fullduplex active adding backward flow using 5%%");
-    for (auto const& link : *back_route)
+    for (auto const& link : back_route)
       lmm_expand(maxminSystem_, link->constraint(), action->getVariable(), .05);
 
     //Change concurrency_share here, if you want that cross-traffic is included in the SURF concurrency
     //(You would also have to change lmm_element_concurrency())
     //lmm_variable_concurrency_share_set(action->getVariable(),2);
   }
-
-  delete route;
-  delete back_route;
   XBT_OUT();
 
   simgrid::s4u::Link::onCommunicate(action, src, dst);
index 3ac508d..7c30095 100644 (file)
@@ -81,10 +81,10 @@ static void clusterCreation_cb(ClusterCreationArgs* cluster)
 static void routeCreation_cb(bool symmetrical, simgrid::kernel::routing::NetPoint* src,
                              simgrid::kernel::routing::NetPoint* dst, simgrid::kernel::routing::NetPoint* gw_src,
                              simgrid::kernel::routing::NetPoint* gw_dst,
-                             std::vector<simgrid::surf::LinkImpl*>* link_list)
+                             std::vector<simgrid::surf::LinkImpl*>& link_list)
 {
-  if (link_list->size() == 1) {
-    simgrid::surf::LinkNS3* link = static_cast<simgrid::surf::LinkNS3*>(link_list->at(0));
+  if (link_list.size() == 1) {
+    simgrid::surf::LinkNS3* link = static_cast<simgrid::surf::LinkNS3*>(link_list[0]);
 
     XBT_DEBUG("Route from '%s' to '%s' with link '%s' %s", src->getCname(), dst->getCname(), link->getCname(),
               (symmetrical ? "(symmetrical)" : "(not symmetrical)"));
@@ -109,7 +109,7 @@ static void routeCreation_cb(bool symmetrical, simgrid::kernel::routing::NetPoin
                "of length 1.\n"
                "WARNING: Remove long routes to avoid this harmless message; subsequent long routes will be silently "
                "ignored.",
-               src->getCname(), dst->getCname(), link_list->size());
+               src->getCname(), dst->getCname(), link_list.size());
     warned_about_long_routes = true;
   }
 }
@@ -219,7 +219,7 @@ void NetworkNS3Model::updateActionsState(double now, double delta)
 
       std::vector<LinkImpl*> route = std::vector<LinkImpl*>();
 
-      action->src_->routeTo(action->dst_, &route, nullptr);
+      action->src_->routeTo(action->dst_, route, nullptr);
       for (auto const& link : route)
         TRACE_surf_link_set_utilization(link->getCname(), action->getCategory(), (data_delta_sent) / delta, now - delta,
                                         delta);
index 17f312c..9e252ee 100644 (file)
@@ -182,7 +182,7 @@ L07Action::L07Action(Model *model, int host_nb, sg_host_t *host_list,
           double lat=0.0;
 
           std::vector<LinkImpl*> route;
-          hostList_->at(i)->routeTo(hostList_->at(j), &route, &lat);
+          hostList_->at(i)->routeTo(hostList_->at(j), route, &lat);
           latency = MAX(latency, lat);
 
           for (auto const& link : route)
@@ -210,7 +210,7 @@ L07Action::L07Action(Model *model, int host_nb, sg_host_t *host_list,
       for (int j = 0; j < host_nb; j++) {
         if (bytes_amount[i * host_nb + j] > 0.0) {
           std::vector<LinkImpl*> route;
-          hostList_->at(i)->routeTo(hostList_->at(j), &route, nullptr);
+          hostList_->at(i)->routeTo(hostList_->at(j), route, nullptr);
 
           for (auto const& link : route)
             lmm_expand_add(model->getMaxminSystem(), link->constraint(), this->getVariable(),
@@ -407,7 +407,7 @@ void L07Action::updateBound()
         if (communicationAmount_[i * hostNb + j] > 0) {
           double lat = 0.0;
           std::vector<LinkImpl*> route;
-          hostList_->at(i)->routeTo(hostList_->at(j), &route, &lat);
+          hostList_->at(i)->routeTo(hostList_->at(j), route, &lat);
 
           lat_current = MAX(lat_current, lat * communicationAmount_[i * hostNb + j]);
         }
index db80cd7..9523a09 100644 (file)
@@ -84,12 +84,12 @@ public:
 };
 
 struct s_sg_platf_route_cbarg_t {
-  bool symmetrical                                 = false;
-  sg_netpoint_t src                                = nullptr;
-  sg_netpoint_t dst                                = nullptr;
-  sg_netpoint_t gw_src                             = nullptr;
-  sg_netpoint_t gw_dst                             = nullptr;
-  std::vector<simgrid::surf::LinkImpl*>* link_list = nullptr;
+  bool symmetrical     = false;
+  sg_netpoint_t src    = nullptr;
+  sg_netpoint_t dst    = nullptr;
+  sg_netpoint_t gw_src = nullptr;
+  sg_netpoint_t gw_dst = nullptr;
+  std::vector<simgrid::surf::LinkImpl*> link_list;
 };
 typedef s_sg_platf_route_cbarg_t* sg_platf_route_cbarg_t;
 
@@ -235,8 +235,6 @@ XBT_PUBLIC(void) surf_parse_set_out(FILE * out_str);
 XBT_PUBLIC(int) surf_parse_get_debug();
 XBT_PUBLIC(void) surf_parse_set_debug(int bdebug);
 XBT_PUBLIC(int) surf_parse_lex_destroy();
-
-XBT_PUBLIC(void) routing_route_free(sg_platf_route_cbarg_t route);
 }
 
 namespace simgrid {
index e370d13..5f34526 100644 (file)
@@ -698,15 +698,11 @@ void ETag_surfxml_route(){
   route.dst         = sg_netpoint_by_name_or_null(A_surfxml_route_dst); // tested to not be nullptr in start tag
   route.gw_src    = nullptr;
   route.gw_dst    = nullptr;
-  route.link_list   = new std::vector<simgrid::surf::LinkImpl*>();
   route.symmetrical = (A_surfxml_route_symmetrical == A_surfxml_route_symmetrical_YES);
 
-  for (auto const& link : parsed_link_list)
-    route.link_list->push_back(link);
-  parsed_link_list.clear();
+  route.link_list.swap(parsed_link_list);
 
   sg_platf_new_route(&route);
-  delete route.link_list;
 }
 
 void ETag_surfxml_ASroute()
@@ -728,11 +724,7 @@ void ETag_surfxml_zoneRoute()
   ASroute.gw_src = sg_netpoint_by_name_or_null(A_surfxml_zoneRoute_gw___src); // tested to not be nullptr in start tag
   ASroute.gw_dst = sg_netpoint_by_name_or_null(A_surfxml_zoneRoute_gw___dst); // tested to not be nullptr in start tag
 
-  ASroute.link_list = new std::vector<simgrid::surf::LinkImpl*>();
-
-  for (auto const& link : parsed_link_list)
-    ASroute.link_list->push_back(link);
-  parsed_link_list.clear();
+  ASroute.link_list.swap(parsed_link_list);
 
   switch (A_surfxml_zoneRoute_symmetrical) {
   case AU_surfxml_zoneRoute_symmetrical:
@@ -747,7 +739,6 @@ void ETag_surfxml_zoneRoute()
   }
 
   sg_platf_new_route(&ASroute);
-  delete ASroute.link_list;
 }
 
 void ETag_surfxml_bypassRoute(){
@@ -758,14 +749,10 @@ void ETag_surfxml_bypassRoute(){
   route.gw_src = nullptr;
   route.gw_dst = nullptr;
   route.symmetrical = false;
-  route.link_list   = new std::vector<simgrid::surf::LinkImpl*>();
 
-  for (auto const& link : parsed_link_list)
-    route.link_list->push_back(link);
-  parsed_link_list.clear();
+  route.link_list.swap(parsed_link_list);
 
   sg_platf_new_bypassRoute(&route);
-  delete route.link_list;
 }
 
 void ETag_surfxml_bypassASroute()
@@ -782,10 +769,7 @@ void ETag_surfxml_bypassZoneRoute()
 
   ASroute.src         = sg_netpoint_by_name_or_null(A_surfxml_bypassZoneRoute_src);
   ASroute.dst         = sg_netpoint_by_name_or_null(A_surfxml_bypassZoneRoute_dst);
-  ASroute.link_list   = new std::vector<simgrid::surf::LinkImpl*>();
-  for (auto const& link : parsed_link_list)
-    ASroute.link_list->push_back(link);
-  parsed_link_list.clear();
+  ASroute.link_list.swap(parsed_link_list);
 
   ASroute.symmetrical = false;
 
@@ -793,7 +777,6 @@ void ETag_surfxml_bypassZoneRoute()
   ASroute.gw_dst = sg_netpoint_by_name_or_null(A_surfxml_bypassZoneRoute_gw___dst);
 
   sg_platf_new_bypassRoute(&ASroute);
-  delete ASroute.link_list;
 }
 
 void ETag_surfxml_trace(){
index 524e44f..cd94fdc 100644 (file)
@@ -131,7 +131,7 @@ static void dump_routes()
       simgrid::s4u::Host* host2 = hosts[it_dst];
       std::vector<simgrid::surf::LinkImpl*> route;
       simgrid::kernel::routing::NetPoint* netcardDst = host2->pimpl_netpoint;
-      simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(netcardSrc, netcardDst, &route, nullptr);
+      simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(netcardSrc, netcardDst, route, nullptr);
       if (not route.empty()) {
         std::printf("  <route src=\"%s\" dst=\"%s\">\n  ", host1->getCname(), host2->getCname());
         for (auto const& link : route)
@@ -144,7 +144,7 @@ static void dump_routes()
       if (netcardDst->isRouter()) {
         std::printf("  <route src=\"%s\" dst=\"%s\">\n  ", host1->getCname(), netcardDst->getCname());
         std::vector<simgrid::surf::LinkImpl*> route;
-        simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(netcardSrc, netcardDst, &route, nullptr);
+        simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(netcardSrc, netcardDst, route, nullptr);
         for (auto const& link : route)
           std::printf("<link_ctn id=\"%s\"/>", link->getCname());
         std::printf("\n  </route>\n");
@@ -158,7 +158,7 @@ static void dump_routes()
         if (value2->isRouter()) {
           std::printf("  <route src=\"%s\" dst=\"%s\">\n  ", value1->getCname(), value2->getCname());
           std::vector<simgrid::surf::LinkImpl*> route;
-          simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(value1, value2, &route, nullptr);
+          simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(value1, value2, route, nullptr);
           for (auto const& link : route)
             std::printf("<link_ctn id=\"%s\"/>", link->getCname());
           std::printf("\n  </route>\n");
@@ -169,7 +169,7 @@ static void dump_routes()
         std::printf("  <route src=\"%s\" dst=\"%s\">\n  ", value1->getCname(), host2->getCname());
         std::vector<simgrid::surf::LinkImpl*> route;
         simgrid::kernel::routing::NetPoint* netcardDst = host2->pimpl_netpoint;
-        simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(value1, netcardDst, &route, nullptr);
+        simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(value1, netcardDst, route, nullptr);
         for (auto const& link : route)
           std::printf("<link_ctn id=\"%s\"/>", link->getCname());
         std::printf("\n  </route>\n");