Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Free some missing variables.
[simgrid.git] / src / surf / surf_routing.c
index 4fb63a4..d0a5328 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 {
@@ -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();
@@ -3314,7 +3317,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 +3444,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 +3734,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 +3900,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;
+         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 +3958,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 +3981,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);
          }
 }