Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't try to push loopback if not defined.
[simgrid.git] / src / surf / surf_routing_floyd.c
index be0e83e..b7a60a5 100644 (file)
@@ -104,7 +104,8 @@ static void floyd_get_route_and_latency(AS_t asg, const char *src, const char *d
 
     if (asg->hierarchy == SURF_ROUTING_RECURSIVE && !first
         && strcmp(gw_dst, prev_gw_src)) {
-      xbt_dynar_t e_route_as_to_as=NULL;
+      xbt_dynar_t e_route_as_to_as;
+      e_route_as_to_as = xbt_dynar_new(global_routing->size_of_link, NULL);
       routing_get_route_and_latency(gw_dst, prev_gw_src,&e_route_as_to_as,NULL);
       links = e_route_as_to_as;
       int pos = 0;
@@ -114,6 +115,7 @@ static void floyd_get_route_and_latency(AS_t asg, const char *src, const char *d
           *lat += surf_network_model->extension.network.get_link_latency(link);
         pos++;
       }
+      xbt_dynar_free(&e_route_as_to_as);
     }
 
     links = e_route->link_list;
@@ -150,8 +152,9 @@ static void floyd_finalize(AS_t rc)
     xbt_dict_free(&as->generic_routing.bypassRoutes);
     /* Delete index dict */
     xbt_dict_free(&(as->generic_routing.to_index));
-    /* Delete dictionary index dict, predecessor and links table */
+    /* Delete predecessor and cost table */
     xbt_free(as->predecessor_table);
+    xbt_free(as->cost_table);
 
     model_generic_finalize(rc);
   }
@@ -197,7 +200,7 @@ void model_floyd_end(AS_t current_routing)
        }
 
        /* Add the loopback if needed */
-       if (current_routing->hierarchy == SURF_ROUTING_BASE) {
+       if (global_routing->loopback && current_routing->hierarchy == SURF_ROUTING_BASE) {
                for (i = 0; i < table_size; i++) {
                  route_t e_route = TO_FLOYD_LINK(i, i);
                  if (!e_route) {
@@ -231,7 +234,7 @@ void model_floyd_end(AS_t current_routing)
        }
 }
 
-static int surf_pointer_resource_cmp(const void *a, const void *b) {
+static int floyd_pointer_resource_cmp(const void *a, const void *b) {
   return a != b;
 }
 
@@ -245,7 +248,6 @@ void model_floyd_parse_route(AS_t rc, const char *src,
        /* set the size of table routing */
        size_t table_size = xbt_dict_length(rc->to_index);
        int *src_id, *dst_id;
-       int i,j;
 
        src_id = xbt_dict_get_or_null(rc->to_index, src);
        dst_id = xbt_dict_get_or_null(rc->to_index, dst);
@@ -255,6 +257,7 @@ void model_floyd_parse_route(AS_t rc, const char *src,
 
        if(!as->link_table)
        {
+          int i,j;
                /* Create Cost, Predecessor and Link tables */
                as->cost_table = xbt_new0(double, table_size * table_size);       /* link cost from host to host */
                as->predecessor_table = xbt_new0(int, table_size * table_size);  /* predecessor host numbers */
@@ -288,7 +291,7 @@ void model_floyd_parse_route(AS_t rc, const char *src,
                xbt_assert(!xbt_dynar_compare(
                          (void*)TO_FLOYD_LINK(*src_id, *dst_id)->link_list,
                          (void*)link_route_to_test,
-                         (int_f_cpvoid_cpvoid_t) surf_pointer_resource_cmp),
+                         (int_f_cpvoid_cpvoid_t) floyd_pointer_resource_cmp),
                          "The route between \"%s\" and \"%s\" already exists", src,dst);
        }
        else
@@ -333,15 +336,15 @@ void model_floyd_parse_route(AS_t rc, const char *src,
                        xbt_assert(!xbt_dynar_compare(
                                  (void*)TO_FLOYD_LINK(*dst_id, *src_id)->link_list,
                              (void*)link_route_to_test,
-                                 (int_f_cpvoid_cpvoid_t) surf_pointer_resource_cmp),
+                                 (int_f_cpvoid_cpvoid_t) floyd_pointer_resource_cmp),
                                  "The route between \"%s\" and \"%s\" already exists", src,dst);
                }
                else
                {
                        if(route->dst_gateway && route->src_gateway)
                        {
-                          char *gw_src = xbt_strdup(route->src_gateway);
-                          char *gw_dst = xbt_strdup(route->dst_gateway);
+                          char *gw_src = route->src_gateway;
+                          char *gw_dst = route->dst_gateway;
                           route->src_gateway = gw_dst;
                           route->dst_gateway = gw_src;
                        }