Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove xbt_assert from generic_src_dst_check function.
[simgrid.git] / src / surf / surf_routing.c
index 4fb63a4..d96443e 100644 (file)
@@ -74,6 +74,7 @@ static void routing_parse_Sconfig(void);        /*config Tag */
 static void routing_parse_Econfig(void);        /*config Tag */
 
 static char* replace_random_parameter(char * chaine);
+static void clean_dict_random(void);
 
 /* this lines are only for replace use like index in the model table */
 typedef enum {
@@ -1068,7 +1069,7 @@ static xbt_dynar_t get_onelink_routes(void)
   return recursive_get_onelink_routes(global_routing->root);
 }
 
-static e_surf_network_element_type_t get_network_element_type(const char
+e_surf_network_element_type_t get_network_element_type(const char
                                                               *name)
 {
   network_element_info_t rc = NULL;
@@ -1134,6 +1135,8 @@ void routing_model_create(size_t size_of_links, void *loopback, double_f_cpvoid_
   surfxml_add_callback(STag_surfxml_peer_cb_list,
                          &routing_parse_Speer);
 
+  surfxml_add_callback(ETag_surfxml_platform_cb_list,
+                                                 &clean_dict_random);
 
 #ifdef HAVE_TRACING
   instr_routing_define_callbacks();
@@ -1790,7 +1793,6 @@ static void model_floyd_set_route(routing_component_t rc, const char *src,
                              (void*)link_route_to_test,
                                  (int_f_cpvoid_cpvoid_t) surf_pointer_resource_cmp),
                                  "The route between \"%s\" and \"%s\" already exists", src,dst);
-                       xbt_free(link_route_to_test);
                }
                else
                {
@@ -3275,7 +3277,6 @@ generic_processing_units_exist(routing_component_t rc, char *element)
 static void generic_src_dst_check(routing_component_t rc, const char *src,
                                   const char *dst)
 {
- #ifndef NDEBUG
   routing_component_t src_as = ((network_element_info_t)
                                 xbt_dict_get_or_null
                                 (global_routing->where_network_elements,
@@ -3284,17 +3285,15 @@ static void generic_src_dst_check(routing_component_t rc, const char *src,
                                 xbt_dict_get_or_null
                                 (global_routing->where_network_elements,
                                  dst))->rc_component;
-
-  xbt_assert3(src_as != NULL && dst_as != NULL,
-              "Ask for route \"from\"(%s) or \"to\"(%s) no found at AS \"%s\"",
+  if(src_as == NULL || dst_as == NULL)
+         xbt_die("Ask for route \"from\"(%s) or \"to\"(%s) no found at AS \"%s\"",
               src, dst, rc->name);
-  xbt_assert4(src_as == dst_as,
-              "The src(%s in %s) and dst(%s in %s) are in differents AS",
+  if(src_as != dst_as)
+         xbt_die("The src(%s in %s) and dst(%s in %s) are in differents AS",
               src, src_as->name, dst, dst_as->name);
-  xbt_assert2(rc == dst_as,
-              "The routing component of src and dst is not the same as the network elements belong (%s==%s)",
-              rc->name, dst_as->name);
-#endif
+  if(rc != dst_as)
+        xbt_die("The routing component of src and dst is not the same as the network elements belong (%s==%s)",
+     rc->name, dst_as->name);
 }
 
 static void routing_parse_Sconfig(void)
@@ -3314,7 +3313,8 @@ static void routing_parse_Econfig(void)
                  xbt_cfg_set_parse(_surf_cfg_set, cfg);
          else
                  XBT_INFO("The custom configuration '%s' is already define by user!",key);
-       }
+         free(cfg);
+  }
   XBT_DEBUG("End configuration name = %s",A_surfxml_config_id);
 }
 
@@ -3440,6 +3440,7 @@ static void routing_parse_Scluster(void)
 
       xbt_free(temp_cluster_bw);
       xbt_free(temp_cluster_lat);
+      xbt_free(temp_cluster_power);
       free(link_id);
       free(host_id);
       break;
@@ -3729,10 +3730,18 @@ static char* replace_random_parameter(char * string)
     xbt_free(string);
     string = test_string;
   } //In other case take old value (without ${})
-
+  else
+       free(test_string);
   return string;
 }
 
+static void clean_dict_random(void)
+{
+       XBT_DEBUG("Clean dict for random");
+       xbt_dict_free(&random_value);
+       xbt_dict_free(&patterns);
+}
+
 static void routing_parse_Speer(void)
 {
   static int AX_ptr = 0;
@@ -3887,6 +3896,8 @@ static void routing_parse_Srandom(void)
          double mean, std, min, max, seed;
          char *random_id = A_surfxml_random_id;
          char *random_radical = A_surfxml_random_radical;
+         char *rd_name = NULL;
+         char *rd_value;
          surf_parse_get_double(&mean,A_surfxml_random_mean);
          surf_parse_get_double(&std,A_surfxml_random_std_deviation);
          surf_parse_get_double(&min,A_surfxml_random_min);
@@ -3943,7 +3954,8 @@ static void routing_parse_Srandom(void)
          if(!strcmp(random_radical,""))
          {
                  res = random_generate(random);
-                 xbt_dict_set(random_value, random_id, bprintf("%f",res), free);
+                 rd_value = bprintf("%f",res);
+                 xbt_dict_set(random_value, random_id, rd_value, free);
          }
          else
          {
@@ -3965,19 +3977,22 @@ static void routing_parse_Srandom(void)
                                          for (i = start; i <= end; i++) {
                                                  xbt_assert1(!xbt_dict_get_or_null(random_value,random_id),"Custom Random '%s' already exists !",bprintf("%s%d",random_id,i));
                                                  res = random_generate(random);
-                                                  tmpbuf = bprintf("%s%d",random_id,i);
+                          tmpbuf = bprintf("%s%d",random_id,i);
                                                  xbt_dict_set(random_value, tmpbuf, bprintf("%f",res), free);
-                                                  xbt_free(tmpbuf);
+                          xbt_free(tmpbuf);
                                          }
                                          break;
                        default:
                                XBT_INFO("Malformed radical");
                        }
                        res = random_generate(random);
-                       xbt_dict_set(random_value, bprintf("%s_router",random_id), bprintf("%f",res), free);
+                       rd_name  = bprintf("%s_router",random_id);
+                       rd_value = bprintf("%f",res);
+                       xbt_dict_set(random_value, rd_name, rd_value, free);
 
                        xbt_dynar_free(&radical_ends);
                  }
+                 free(rd_name);
                  xbt_dynar_free(&radical_elements);
          }
 }