Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
What's not malloced cannot be leaked
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 17 Apr 2016 12:43:06 +0000 (14:43 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 17 Apr 2016 12:43:09 +0000 (14:43 +0200)
The core of this change is the following:
--- a/src/surf/xml/platf_private.hpp
+++ b/src/surf/xml/platf_private.hpp
@@ -91,7 +91,7 @@ typedef struct s_sg_platf_route_cbarg {
   const char *dst;
   sg_netcard_t gw_src;
   sg_netcard_t gw_dst;
-  std::vector<Link*> *link_list;
+  std::vector<Link*> link_list;
 } s_sg_platf_route_cbarg_t;

-----------

The rest of the changes are just code adaptation to that change.

13 files changed:
src/bindings/lua/lua_platf.cpp
src/s4u/s4u_as.cpp
src/surf/AsCluster.cpp
src/surf/AsClusterFatTree.cpp
src/surf/AsClusterTorus.cpp
src/surf/AsDijkstra.cpp
src/surf/AsFloyd.cpp
src/surf/AsFull.cpp
src/surf/AsImpl.cpp
src/surf/AsRoutedGraph.cpp
src/surf/AsVivaldi.cpp
src/surf/xml/platf_private.hpp
src/surf/xml/surfxml_sax_cb.cpp

index 9d52127..7775b95 100644 (file)
@@ -338,11 +338,10 @@ 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<Link*>();
   xbt_dynar_t names = xbt_str_split(lua_tostring(L, -1), ", \t\r\n");
   if (xbt_dynar_is_empty(names)) {
     /* unique name */
-    route.link_list->push_back(Link::byName(lua_tostring(L, -1)));
+    route.link_list.push_back(Link::byName(lua_tostring(L, -1)));
   } else {
     // Several names separated by , \t\r\n
     unsigned int cpt;
@@ -350,7 +349,7 @@ int console_add_route(lua_State *L) {
     xbt_dynar_foreach(names, cpt, name) {
       if (strlen(name)>0) {
         Link *link = Link::byName(name);
-        route.link_list->push_back(link);
+        route.link_list.push_back(link);
       }
     }
   }
@@ -414,11 +413,10 @@ int console_add_ASroute(lua_State *L) {
 
   lua_pushstring(L,"links");
   lua_gettable(L,-2);
-  ASroute.link_list = new std::vector<Link*>();
   xbt_dynar_t names = xbt_str_split(lua_tostring(L, -1), ", \t\r\n");
   if (xbt_dynar_is_empty(names)) {
     /* unique name with no comma */
-    ASroute.link_list->push_back(Link::byName(lua_tostring(L, -1)));
+    ASroute.link_list.push_back(Link::byName(lua_tostring(L, -1)));
   } else {
     // Several names separated by , \t\r\n
     unsigned int cpt;
@@ -426,7 +424,7 @@ int console_add_ASroute(lua_State *L) {
     xbt_dynar_foreach(names, cpt, name) {
       if (strlen(name)>0) {
         Link *link = Link::byName(name);
-        ASroute.link_list->push_back(link);
+        ASroute.link_list.push_back(link);
       }
     }
   }
index b0f760f..ec748ab 100644 (file)
@@ -82,19 +82,19 @@ namespace simgrid {
       if (e_route->gw_dst) {
         XBT_DEBUG("Load bypassASroute from %s@%s to %s@%s",
             src, e_route->gw_src->name(), dst, e_route->gw_dst->name());
-        xbt_assert(!e_route->link_list->empty(), "Bypass route between %s@%s and %s@%s cannot be empty.",
+        xbt_assert(!e_route->link_list.empty(), "Bypass route between %s@%s and %s@%s cannot be empty.",
             src, e_route->gw_src->name(), dst, e_route->gw_dst->name());
         xbt_assert(bypassRoutes_.find({src,dst}) == bypassRoutes_.end(), "The bypass route between %s@%s and %s@%s already exists.",
             src, e_route->gw_src->name(), dst, e_route->gw_dst->name());
       } else {
         XBT_DEBUG("Load bypassRoute from %s to %s", src, dst);
-        xbt_assert(!e_route->link_list->empty(),                         "Bypass route between %s and %s cannot be empty.",    src, dst);
+        xbt_assert(!e_route->link_list.empty(),                         "Bypass route between %s and %s cannot be empty.",    src, dst);
         xbt_assert(bypassRoutes_.find({src,dst}) == bypassRoutes_.end(), "The bypass route between %s and %s already exists.", src, dst);
       }
 
       /* Build a copy that will be stored in the dict */
       std::vector<surf::Link*> *newRoute = new std::vector<surf::Link*>();
-      for (auto link: *e_route->link_list)
+      for (auto link: e_route->link_list)
         newRoute->push_back(link);
 
       /* Store it */
index 8fe7144..cd79138 100644 (file)
@@ -32,7 +32,7 @@ void AsCluster::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb
 
     if((src->id() == dst->id()) && has_loopback_  ){
       info = xbt_dynar_get_as(privateLinks_, src->id() * nb_links_per_node_, s_surf_parsing_link_up_down_t);
-      route->link_list->push_back(info.link_up);
+      route->link_list.push_back(info.link_up);
       if (lat)
         *lat += info.link_up->getLatency();
       return;
@@ -41,12 +41,12 @@ void AsCluster::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb
 
     if (has_limiter_){          // limiter for sender
       info = xbt_dynar_get_as(privateLinks_, src->id() * nb_links_per_node_ + has_loopback_, s_surf_parsing_link_up_down_t);
-      route->link_list->push_back((Link*)info.link_up);
+      route->link_list.push_back((Link*)info.link_up);
     }
 
     info = xbt_dynar_get_as(privateLinks_, src->id() * nb_links_per_node_ + has_loopback_ + has_limiter_, s_surf_parsing_link_up_down_t);
     if (info.link_up) {         // link up
-      route->link_list->push_back(info.link_up);
+      route->link_list.push_back(info.link_up);
       if (lat)
         *lat += info.link_up->getLatency();
     }
@@ -54,7 +54,7 @@ void AsCluster::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb
   }
 
   if (backbone_) {
-    route->link_list->push_back(backbone_);
+    route->link_list.push_back(backbone_);
     if (lat)
       *lat += backbone_->getLatency();
   }
@@ -63,20 +63,19 @@ void AsCluster::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb
     info = xbt_dynar_get_as(privateLinks_, dst->id() * nb_links_per_node_ + has_loopback_ + has_limiter_, s_surf_parsing_link_up_down_t);
 
     if (info.link_down) {       // link down
-      route->link_list->push_back(info.link_down);
+      route->link_list.push_back(info.link_down);
       if (lat)
         *lat += info.link_down->getLatency();
     }
     if (has_limiter_){          // limiter for receiver
         info = xbt_dynar_get_as(privateLinks_, dst->id() * nb_links_per_node_ + has_loopback_, s_surf_parsing_link_up_down_t);
-        route->link_list->push_back(info.link_up);
+        route->link_list.push_back(info.link_up);
     }
   }
 }
 
 void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
 {
-  int isrc;
   int table_size = xbt_dynar_length(vertices_);
 
   NetCard *src;
@@ -96,7 +95,7 @@ void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
     new_xbt_graph_edge(graph, routerNode, backboneNode, edges);
   }
 
-  for (isrc = 0; isrc < table_size; isrc++) {
+  for (int isrc = 0; isrc < table_size; isrc++) {
     src = xbt_dynar_get_as(vertices_, isrc, NetCard*);
 
     if (! src->isRouter()) {
index 2f99736..9125616 100644 (file)
@@ -93,7 +93,7 @@ void AsClusterFatTree::getRouteAndLatency(NetCard *src,
   /* In case destination is the source, and there is a loopback, let's get
      through it instead of going up to a switch*/
   if(source->id == destination->id && this->has_loopback_) {
-    into->link_list->push_back(source->loopback);
+    into->link_list.push_back(source->loopback);
     if(latency) {
       *latency += source->loopback->getLatency();
     }
@@ -112,14 +112,14 @@ void AsClusterFatTree::getRouteAndLatency(NetCard *src,
     }
     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->getLatency();
     }
 
     if (this->has_limiter_) {
-      into->link_list->push_back(currentNode->limiterLink);
+      into->link_list.push_back(currentNode->limiterLink);
     }
     currentNode = currentNode->parents[d]->upNode;
   }
@@ -133,13 +133,13 @@ void AsClusterFatTree::getRouteAndLatency(NetCard *src,
     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->getLatency();
         }
         currentNode = currentNode->children[i]->downNode;
         if (this->has_limiter_) {
-          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,
index 223c068..31f6524 100644 (file)
@@ -120,7 +120,7 @@ namespace simgrid {
       if ((src->id() == dst->id()) && has_loopback_) {
         s_surf_parsing_link_up_down_t info = xbt_dynar_get_as(privateLinks_, src->id() * nb_links_per_node_, s_surf_parsing_link_up_down_t);
 
-        route->link_list->push_back(info.link_up);
+        route->link_list.push_back(info.link_up);
         if (lat)
           *lat += info.link_up->getLatency();
         return;
@@ -201,17 +201,17 @@ namespace simgrid {
 
         if (has_limiter_) {    // limiter for sender
           info = xbt_dynar_get_as(privateLinks_, nodeOffset + has_loopback_, s_surf_parsing_link_up_down_t);
-          route->link_list->push_back(info.link_up);
+          route->link_list.push_back(info.link_up);
         }
 
         info = xbt_dynar_get_as(privateLinks_, linkOffset, s_surf_parsing_link_up_down_t);
 
         if (use_lnk_up == false) {
-          route->link_list->push_back(info.link_down);
+          route->link_list.push_back(info.link_down);
           if (lat)
             *lat += info.link_down->getLatency();
         } else {
-          route->link_list->push_back(info.link_up);
+          route->link_list.push_back(info.link_up);
           if (lat)
             *lat += info.link_up->getLatency();
         }
index ec9af59..57845ae 100644 (file)
@@ -28,10 +28,7 @@ static void graph_node_map_elem_free(void *e)
 static void graph_edge_data_free(void *e) // FIXME: useless code duplication
 {
   sg_platf_route_cbarg_t e_route = (sg_platf_route_cbarg_t) e;
-  if (e_route) {
-    delete e_route->link_list;
-    xbt_free(e_route);
-  }
+  xbt_free(e_route);
 }
 
 /* Utility functions */
@@ -64,8 +61,7 @@ void AsDijkstra::seal()
 
       if (!found) {
         sg_platf_route_cbarg_t e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
-        e_route->link_list = new std::vector<Link*>();
-        e_route->link_list->push_back(routing_platf->loopback_);
+        e_route->link_list.push_back(routing_platf->loopback_);
         xbt_graph_new_edge(routeGraph_, node, node, e_route);
       }
     }
@@ -167,8 +163,8 @@ void AsDijkstra::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_c
 
     e_route = (sg_platf_route_cbarg_t) xbt_graph_edge_get_data(edge);
 
-    for (auto link: *e_route->link_list) {
-      route->link_list->insert(route->link_list->begin(), link);
+    for (auto link: e_route->link_list) {
+      route->link_list.insert(route->link_list.begin(), link);
       if (lat)
         *lat += static_cast<Link*>(link)->getLatency();
     }
@@ -218,7 +214,7 @@ void AsDijkstra::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_c
         graph_node_data_t data = (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 = (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;
@@ -262,17 +258,17 @@ void AsDijkstra::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_c
       std::vector<Link*> *e_route_as_to_as = new std::vector<Link*>();
 
       routing_platf->getRouteAndLatency(gw_dst_net_elm, prev_gw_src_net_elm, e_route_as_to_as, NULL);
-      auto pos = route->link_list->begin();
+      auto pos = route->link_list.begin();
       for (auto link : *e_route_as_to_as) {
-        route->link_list->insert(pos, link);
+        route->link_list.insert(pos, link);
         if (lat)
           *lat += link->getLatency();
         pos++;
       }
     }
 
-    for (auto link: *e_route->link_list) {
-      route->link_list->insert(route->link_list->begin(), link);
+    for (auto link: e_route->link_list) {
+      route->link_list.insert(route->link_list.begin(), link);
       if (lat)
         *lat += static_cast<Link*>(link)->getLatency();
     }
index 960b039..6f215c5 100644 (file)
@@ -68,11 +68,11 @@ void AsFloyd::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbar
     sg_platf_route_cbarg_t e_route = xbt_dynar_pop_as(route_stack, sg_platf_route_cbarg_t);
 
     if (hierarchy_ == RoutingMode::recursive && prev_dst_gw != NULL && strcmp(prev_dst_gw->name(), e_route->gw_src->name())) {
-      routing_platf->getRouteAndLatency(prev_dst_gw, e_route->gw_src, route->link_list, lat);
+      routing_platf->getRouteAndLatency(prev_dst_gw, e_route->gw_src, &route->link_list, lat);
     }
 
-    for (auto link: *e_route->link_list) {
-      route->link_list->push_back(link);
+    for (auto link: e_route->link_list) {
+      route->link_list.push_back(link);
       if (lat)
         *lat += link->getLatency();
     }
@@ -118,7 +118,7 @@ void AsFloyd::addRoute(sg_platf_route_cbarg_t route)
 
   TO_FLOYD_LINK(src->id(), dst->id()) = newExtendedRoute(hierarchy_, route, 1);
   TO_FLOYD_PRED(src->id(), dst->id()) = src->id();
-  TO_FLOYD_COST(src->id(), dst->id()) = (TO_FLOYD_LINK(src->id(), dst->id()))->link_list->size();
+  TO_FLOYD_COST(src->id(), dst->id()) = (TO_FLOYD_LINK(src->id(), dst->id()))->link_list.size();
 
 
   if (route->symmetrical == true) {
@@ -145,7 +145,7 @@ void AsFloyd::addRoute(sg_platf_route_cbarg_t route)
 
     TO_FLOYD_LINK(dst->id(), src->id()) = newExtendedRoute(hierarchy_, route, 0);
     TO_FLOYD_PRED(dst->id(), src->id()) = dst->id();
-    TO_FLOYD_COST(dst->id(), src->id()) = (TO_FLOYD_LINK(dst->id(), src->id()))->link_list->size();   /* count of links, old model assume 1 */
+    TO_FLOYD_COST(dst->id(), src->id()) = (TO_FLOYD_LINK(dst->id(), src->id()))->link_list.size();   /* count of links, old model assume 1 */
   }
 }
 
@@ -177,8 +177,7 @@ void AsFloyd::seal(){
         e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
         e_route->gw_src = NULL;
         e_route->gw_dst = NULL;
-        e_route->link_list = new std::vector<Link*>();
-        e_route->link_list->push_back(routing_platf->loopback_);
+        e_route->link_list.push_back(routing_platf->loopback_);
         TO_FLOYD_LINK(i, i) = e_route;
         TO_FLOYD_PRED(i, i) = i;
         TO_FLOYD_COST(i, i) = 1;
index 37d3ff7..07c5851 100644 (file)
@@ -36,8 +36,7 @@ void AsFull::seal() {
         e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
         e_route->gw_src = NULL;
         e_route->gw_dst = NULL;
-        e_route->link_list = new std::vector<Link*>();
-        e_route->link_list->push_back(routing_platf->loopback_);
+        e_route->link_list.push_back(routing_platf->loopback_);
         TO_ROUTE_FULL(i, i) = e_route;
       }
     }
@@ -47,15 +46,11 @@ void AsFull::seal() {
 AsFull::~AsFull(){
   if (routingTable_) {
     int table_size = (int)xbt_dynar_length(vertices_);
-    int i, j;
     /* Delete routing table */
-    for (i = 0; i < table_size; i++)
-      for (j = 0; j < table_size; j++) {
-        if (TO_ROUTE_FULL(i,j)){
-          delete TO_ROUTE_FULL(i,j)->link_list;
+    for (int i = 0; i < table_size; i++)
+      for (int j = 0; j < table_size; j++)
+        if (TO_ROUTE_FULL(i,j))
           xbt_free(TO_ROUTE_FULL(i,j));
-        }
-      }
     xbt_free(routingTable_);
   }
 }
@@ -75,8 +70,8 @@ void AsFull::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg
   if (e_route) {
     res->gw_src = e_route->gw_src;
     res->gw_dst = e_route->gw_dst;
-    for (auto link : *e_route->link_list) {
-      res->link_list->push_back(link);
+    for (auto link : e_route->link_list) {
+      res->link_list.push_back(link);
       if (lat)
         *lat += static_cast<Link*>(link)->getLatency();
     }
@@ -108,7 +103,7 @@ void AsFull::addRoute(sg_platf_route_cbarg_t route)
 
   /* Add the route to the base */
   TO_ROUTE_FULL(src_net_elm->id(), dst_net_elm->id()) = newExtendedRoute(hierarchy_, route, 1);
-  TO_ROUTE_FULL(src_net_elm->id(), dst_net_elm->id())->link_list->shrink_to_fit();
+  TO_ROUTE_FULL(src_net_elm->id(), dst_net_elm->id())->link_list.shrink_to_fit();
 
   if (route->symmetrical == true && src_net_elm != dst_net_elm) {
     if (route->gw_dst && route->gw_src) {
@@ -125,7 +120,7 @@ void AsFull::addRoute(sg_platf_route_cbarg_t route)
           "The route between %s and %s already exists. You should not declare the reverse path as symmetrical.", dst,src);
 
     TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id()) = newExtendedRoute(hierarchy_, route, 0);
-    TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id())->link_list->shrink_to_fit();
+    TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id())->link_list.shrink_to_fit();
   }
 }
 
index 3a9f80e..5fb43f4 100644 (file)
@@ -192,15 +192,14 @@ namespace simgrid {
 
       /* If src and dst are in the same AS, life is good */
       if (src_ancestor == dst_ancestor) {       /* SURF_ROUTING_BASE */
-        route.link_list = links;
         common_ancestor->getRouteAndLatency(src, dst, &route, latency);
+        for (surf::Link *link : route.link_list)
+          links->push_back(link);
         return;
       }
 
       /* Not in the same AS, no bypass. We'll have to find our path between the ASes recursively*/
 
-      route.link_list = new std::vector<surf::Link*>();
-
       common_ancestor->getRouteAndLatency(src_ancestor->netcard_, dst_ancestor->netcard_, &route, latency);
       xbt_assert((route.gw_src != NULL) && (route.gw_dst != NULL),
           "bad gateways for route from \"%s\" to \"%s\"", src->name(), dst->name());
@@ -208,14 +207,12 @@ namespace simgrid {
       /* If source gateway is not our source, we have to recursively find our way up to this point */
       if (src != route.gw_src)
         getRouteRecursive(src, route.gw_src, links, latency);
-      for (auto link: *route.link_list)
+      for (auto 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)
         getRouteRecursive(route.gw_dst, dst, links, latency);
-
     }
-
   }
 };
index e58e197..503f600 100644 (file)
@@ -16,10 +16,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_routing_generic, surf_route, "Generic imple
 
 void routing_route_free(sg_platf_route_cbarg_t route)
 {
-  if (route) {
-    delete route->link_list;
-    xbt_free(route);
-  }
+  xbt_free(route);
 }
 
 namespace simgrid {
@@ -89,18 +86,17 @@ namespace surf {
   {
     xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f);
     sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t,1);
-    route->link_list = new std::vector<Link*>();
 
     int table_size = (int)xbt_dynar_length(vertices_);
     for(int src=0; src < table_size; src++) {
       for(int dst=0; dst< table_size; dst++) {
-        route->link_list->clear();
+        route->link_list.clear();
         NetCard *src_elm = xbt_dynar_get_as(vertices_, src, NetCard*);
         NetCard *dst_elm = xbt_dynar_get_as(vertices_, dst, NetCard*);
         this->getRouteAndLatency(src_elm, dst_elm,route, NULL);
 
-        if (route->link_list->size() == 1) {
-          Link *link = route->link_list->at(0);
+        if (route->link_list.size() == 1) {
+          Link *link = route->link_list.at(0);
           Onelink *onelink;
           if (hierarchy_ == RoutingMode::base)
             onelink = new Onelink(link, src_elm, dst_elm);
@@ -131,7 +127,6 @@ void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edg
           xbt_dynar_get_as(vertices_, dst, NetCard*);
 
       sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
-      route->link_list = new std::vector<Link*>();
 
       getRouteAndLatency(my_src, my_dst, route, NULL);
 
@@ -148,7 +143,7 @@ void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edg
         previous_name = my_src->name();
       }
 
-      for (auto link: *route->link_list) {
+      for (auto link: route->link_list) {
         const char *link_name = link->getName();
         current = new_xbt_graph_node(graph, link_name, nodes);
         current_name = link_name;
@@ -168,7 +163,6 @@ void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edg
       new_xbt_graph_edge(graph, previous, current, edges);
       XBT_DEBUG ("  %s -> %s", previous_name, current_name);
 
-      delete route->link_list;
       xbt_free (route);
     }
   }
@@ -183,7 +177,6 @@ sg_platf_route_cbarg_t AsRoutedGraph::newExtendedRoute(RoutingMode hierarchy, sg
   sg_platf_route_cbarg_t result;
 
   result = xbt_new0(s_sg_platf_route_cbarg_t, 1);
-  result->link_list = new std::vector<Link*>();
 
   xbt_assert(hierarchy == RoutingMode::base || hierarchy == RoutingMode::recursive,
       "The hierarchy of this AS is neither BASIC nor RECURSIVE, I'm lost here.");
@@ -195,11 +188,11 @@ sg_platf_route_cbarg_t AsRoutedGraph::newExtendedRoute(RoutingMode hierarchy, sg
     result->gw_dst = routearg->gw_dst;
   }
 
-  for (auto link : *routearg->link_list) {
+  for (auto 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);
   }
 
   return result;
@@ -230,7 +223,7 @@ void AsRoutedGraph::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(! route->link_list->empty(), "Empty route (between %s and %s) forbidden.", srcName, dstName);
+    xbt_assert(! route->link_list.empty(), "Empty route (between %s and %s) forbidden.", srcName, dstName);
     xbt_assert(! src->isAS(), "When defining a route, src cannot be an AS such as '%s'. Did you meant to have an ASroute?", srcName);
     xbt_assert(! dst->isAS(), "When defining a route, dst cannot be an AS such as '%s'. Did you meant to have an ASroute?", dstName);
   } else {
@@ -249,7 +242,7 @@ void AsRoutedGraph::addRouteCheckParams(sg_platf_route_cbarg_t route) {
         srcName,route->gw_src->name(), dstName,route->gw_dst->name(), srcName);
     xbt_assert(dst, "Cannot add a route from %s@%s to %s@%s: %s does not exist.",
         srcName,route->gw_src->name(), dstName,route->gw_dst->name(), dstName);
-    xbt_assert(! route->link_list->empty(), "Empty route (between %s@%s and %s@%s) forbidden.",
+    xbt_assert(! route->link_list.empty(), "Empty route (between %s@%s and %s@%s) forbidden.",
         srcName,route->gw_src->name(), dstName,route->gw_dst->name());
   }
 }
index 1a17446..682afe3 100644 (file)
@@ -64,7 +64,7 @@ void AsVivaldi::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb
   if ((int)xbt_dynar_length(privateLinks_) > src->id()) {
     s_surf_parsing_link_up_down_t info = xbt_dynar_get_as(privateLinks_, src->id(), s_surf_parsing_link_up_down_t);
     if(info.link_up) {
-      route->link_list->push_back(info.link_up);
+      route->link_list.push_back(info.link_up);
       if (lat)
         *lat += info.link_up->getLatency();
     }
@@ -72,7 +72,7 @@ void AsVivaldi::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb
   if ((int)xbt_dynar_length(privateLinks_)>dst->id()) {
     s_surf_parsing_link_up_down_t info = xbt_dynar_get_as(privateLinks_, dst->id(), s_surf_parsing_link_up_down_t);
     if(info.link_down) {
-      route->link_list->push_back(info.link_down);
+      route->link_list.push_back(info.link_down);
       if (lat)
         *lat += info.link_down->getLatency();
     }
index 3d21302..df823bb 100644 (file)
@@ -91,7 +91,7 @@ typedef struct s_sg_platf_route_cbarg {
   const char *dst;
   sg_netcard_t gw_src;
   sg_netcard_t gw_dst;
-  std::vector<Link*> *link_list;
+  std::vector<Link*> link_list;
 } s_sg_platf_route_cbarg_t;
 
 typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
index 3d2e6a3..bf7b20e 100644 (file)
@@ -728,18 +728,16 @@ void ETag_surfxml_route(void){
   route.dst       = A_surfxml_route_dst;
   route.gw_src    = nullptr;
   route.gw_dst    = nullptr;
-  route.link_list = new std::vector<Link*>();
   route.symmetrical = (A_surfxml_route_symmetrical == A_surfxml_route_symmetrical_YES);
 
   unsigned int cpt;
   char *link_name;
   xbt_dynar_foreach(parsed_link_list, cpt, link_name) {
     simgrid::surf::Link *link = Link::byName(link_name);
-    route.link_list->push_back(link);
+    route.link_list.push_back(link);
   }
 
   sg_platf_new_route(&route);
-  delete route.link_list;
   xbt_dynar_free(&parsed_link_list);
 }
 
@@ -760,13 +758,12 @@ void ETag_surfxml_ASroute(void){
     surf_parse_error("gw_dst=\"%s\" not found for ASroute from \"%s\" to \"%s\"",
                      A_surfxml_ASroute_gw___dst, ASroute.src, ASroute.dst);
 
-  ASroute.link_list =  new std::vector<Link*>();
 
   unsigned int cpt;
   char *link_name;
   xbt_dynar_foreach(parsed_link_list, cpt, link_name) {
     simgrid::surf::Link *link = Link::byName(link_name);
-    ASroute.link_list->push_back(link);
+    ASroute.link_list.push_back(link);
   }
   xbt_dynar_free(&parsed_link_list);
 
@@ -792,13 +789,12 @@ void ETag_surfxml_bypassRoute(void){
   route.gw_src = nullptr;
   route.gw_dst = nullptr;
   route.symmetrical = false;
-  route.link_list =  new std::vector<Link*>();
 
   unsigned int cpt;
   char *link_name;
   xbt_dynar_foreach(parsed_link_list, cpt, link_name) {
     simgrid::surf::Link *link = Link::byName(link_name);
-    route.link_list->push_back(link);
+    route.link_list.push_back(link);
   }
   xbt_dynar_free(&parsed_link_list);
 
@@ -811,12 +807,11 @@ void ETag_surfxml_bypassASroute(void){
 
   ASroute.src         = A_surfxml_bypassASroute_src;
   ASroute.dst         = A_surfxml_bypassASroute_dst;
-  ASroute.link_list   =  new std::vector<Link*>();
   unsigned int cpt;
   char *link_name;
   xbt_dynar_foreach(parsed_link_list, cpt, link_name) {
     simgrid::surf::Link *link = Link::byName(link_name);
-    ASroute.link_list->push_back(link);
+    ASroute.link_list.push_back(link);
   }
   xbt_dynar_free(&parsed_link_list);
   ASroute.symmetrical = false;