Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Factorize some code in the parser, hide some functions and variables, avoid useless...
authoralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 10 Jun 2008 12:59:38 +0000 (12:59 +0000)
committeralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 10 Jun 2008 12:59:38 +0000 (12:59 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5596 48e7efb5-ca39-0410-a469-dd3cf9ba447f

examples/msg/masterslave/masterslave_bypass.tesh
src/include/surf/surf.h
src/surf/network.c
src/surf/network_constant.c
src/surf/surfxml_parse.c
src/surf/workstation_ptask_L07.c

index ad40592..92dba09 100644 (file)
@@ -3,7 +3,7 @@ p Testing the bypassing of the flexml parser
 
 
 $ $SG_TEST_EXENV masterslave/masterslave_bypass
-> [0.000000] surf/surfxml_parse.c:410: [surf_parse/WARNING] Bypassing the XML parser since surf_parse_open received a NULL pointer. If it is not what you want, go fix your code.
+> [0.000000] surf/surfxml_parse.c:409: [surf_parse/WARNING] Bypassing the XML parser since surf_parse_open received a NULL pointer. If it is not what you want, go fix your code.
 > [host A:master:(1) 0.000000] [msg_test/INFO] Got 1 slave(s) :
 > [host A:master:(1) 0.000000] [msg_test/INFO]          host B
 > [host A:master:(1) 0.000000] [msg_test/INFO] Got 20 task to process :
index ff5fbbb..d5d78df 100644 (file)
@@ -580,10 +580,6 @@ XBT_PUBLIC(void) surf_exit(void);
 XBT_PUBLIC_DATA(xbt_dict_t) current_property_set; /* the prop set for the currently parsed element (also used in SIMIX) */
 void parse_properties(void);
 
-/* Prototypes for functions handling routing and were factorized succesfully from the models */
-void init_data(void);
-void parse_route_elem(void);
-
 /* surf parse file related (public because called from a test suite) */
 XBT_PUBLIC(void) parse_platform_file(const char* file);
 
@@ -605,9 +601,7 @@ XBT_PUBLIC_DATA(int) route_action;
 /* This is used by all models when creating the routing table while parsing */
 XBT_PUBLIC_DATA(xbt_dict_t) route_table;
 XBT_PUBLIC_DATA(xbt_dict_t) route_multi_table;
-XBT_PUBLIC_DATA(xbt_dict_t) route_table;
 XBT_PUBLIC_DATA(xbt_dict_t) route_multi_table;
-XBT_PUBLIC_DATA(xbt_dynar_t) route_link_list;
 
 /* For the trace and trace:connect tag (store their content till the end of the parsing) */
 XBT_PUBLIC_DATA(xbt_dict_t) traces_set_list;
index c195b2e..6c2c6c1 100644 (file)
@@ -161,7 +161,6 @@ static void parse_route_set_endpoints(void)
   src_id = network_card_new(A_surfxml_route_src);
   dst_id = network_card_new(A_surfxml_route_dst);
   route_action = A_surfxml_route_action;
-  route_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
 }
 
 static void parse_route_set_route(void)
@@ -228,9 +227,6 @@ static void add_route(void)
     }
     route_new(src_id, dst_id, link_list, nb_link);
    }
-
-   xbt_dict_free(&route_table);
-
 }
 
 static void count_hosts(void)
@@ -294,9 +290,7 @@ static void define_callbacks(const char *file)
   surfxml_add_callback(STag_surfxml_link_cb_list, &parse_link_init);
   surfxml_add_callback(STag_surfxml_prop_cb_list, &parse_properties);
   surfxml_add_callback(STag_surfxml_route_cb_list, &parse_route_set_endpoints);
-  surfxml_add_callback(ETag_surfxml_link_c_ctn_cb_list, &parse_route_elem);
   surfxml_add_callback(ETag_surfxml_route_cb_list, &parse_route_set_route);
-  surfxml_add_callback(STag_surfxml_platform_cb_list, &init_data);
   surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_traces);
   surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_route);
   surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_loopback);
index 0cb800c..83cef7c 100644 (file)
@@ -59,7 +59,6 @@ static void parse_route_set_endpoints(void)
   src_id = network_card_new(A_surfxml_route_src);
   dst_id = network_card_new(A_surfxml_route_dst);
   route_action = A_surfxml_route_action;
-  route_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
 }
 
 static void parse_route_set_route(void)
@@ -83,9 +82,7 @@ static void define_callbacks(const char *file)
   surfxml_add_callback(STag_surfxml_host_cb_list, &count_hosts);
   surfxml_add_callback(STag_surfxml_prop_cb_list, &parse_properties);
   surfxml_add_callback(STag_surfxml_route_cb_list, &parse_route_set_endpoints);
-  surfxml_add_callback(ETag_surfxml_link_c_ctn_cb_list, &parse_route_elem);
   surfxml_add_callback(ETag_surfxml_route_cb_list, &parse_route_set_route);
-  surfxml_add_callback(STag_surfxml_platform_cb_list, &init_data);
   surfxml_add_callback(STag_surfxml_set_cb_list, &parse_sets);
   surfxml_add_callback(STag_surfxml_route_c_multi_cb_list, &parse_route_multi_set_endpoints);
   surfxml_add_callback(ETag_surfxml_route_c_multi_cb_list, &parse_route_multi_set_route);
index a0f189b..3d1724a 100644 (file)
@@ -80,7 +80,7 @@ xbt_dict_t current_property_set = NULL;
 xbt_dict_t route_table = NULL;
 xbt_dict_t route_multi_table = NULL;
 xbt_dynar_t route_multi_elements = NULL;
-xbt_dynar_t route_link_list = NULL;
+static xbt_dynar_t route_link_list = NULL;
 xbt_dynar_t links = NULL;
 xbt_dynar_t keys = NULL;
 
@@ -95,6 +95,7 @@ YY_BUFFER_STATE surf_input_buffer;
 FILE *surf_file_to_parse = NULL;
 
 static void convert_route_multi_to_routes(void);
+static void parse_route_elem(void);
 
 void surf_parse_free_callbacks(void)
 {
@@ -229,10 +230,8 @@ void ETag_surfxml_platform(void)
 
   surfxml_call_cb_functions(ETag_surfxml_platform_cb_list);
 
-  xbt_dynar_free(&route_link_list);
   xbt_dict_free(&random_data_list);
   xbt_dict_free(&set_list);
-
 }
 
 void STag_surfxml_host(void)
@@ -496,7 +495,11 @@ static XBT_INLINE void surfxml_call_cb_functions(xbt_dynar_t cb_list)
     }
 }
 
-void init_data(void)
+static void parse_route_set_endpoints(void) {
+  route_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
+}
+
+static void init_data(void)
 {
   xbt_dict_free(&route_table);
   xbt_dynar_free(&route_link_list);
@@ -513,12 +516,29 @@ void init_data(void)
   trace_connect_list_latency = xbt_dict_new();
 
   random_data_list = xbt_dict_new();
+  surfxml_add_callback(ETag_surfxml_link_c_ctn_cb_list, &parse_route_elem);
+  surfxml_add_callback(STag_surfxml_route_cb_list, &parse_route_set_endpoints);
+}
+
+static void free_data(void) 
+{
+  char *key,*data;
+  xbt_dict_cursor_t cursor = NULL;
+
+  xbt_dict_foreach(route_table, cursor, key, data) {
+    xbt_dynar_t links = (xbt_dynar_t)data;
+    xbt_dynar_free(&links);
+  }
+  xbt_dict_free(&route_table);
+  route_link_list = NULL;
 }
 
 void parse_platform_file(const char* file)
 {
   surf_parse_open(file);
+  init_data();
   xbt_assert1((!(*surf_parse)()), "Parse error in %s", file);
+  free_data();
   surf_parse_close();
 }
 
@@ -734,7 +754,7 @@ static int route_multi_size=0;
 static char* src_name, *dst_name;
 static int is_symmetric_route;
 
-void parse_route_elem(void)
+static void parse_route_elem(void)
 {
   char *val;
 
index 4866f77..b72a43d 100644 (file)
@@ -868,8 +868,6 @@ static void parse_route_set_endpoints(void)
     dst_id = cpu_tmp->id;
 
   route_action = A_surfxml_route_action;
-
-  route_link_list = xbt_dynar_new(sizeof(char*), &xbt_free_ref);
 }
 
 static void parse_route_set_route(void)
@@ -938,8 +936,6 @@ static void add_route(void)
        }
        route_new(src_id, dst_id, link_list, nb_link);
    }
-
-   xbt_dict_free(&route_table);
 }
 
 static void add_traces(void) {   
@@ -1044,9 +1040,7 @@ static void define_callbacks(const char *file)
   surfxml_add_callback(STag_surfxml_prop_cb_list, &parse_properties);
   surfxml_add_callback(STag_surfxml_link_cb_list, &parse_link_init);
   surfxml_add_callback(STag_surfxml_route_cb_list, &parse_route_set_endpoints);
-  surfxml_add_callback(ETag_surfxml_link_c_ctn_cb_list, &parse_route_elem);
   surfxml_add_callback(ETag_surfxml_route_cb_list, &parse_route_set_route);
-  surfxml_add_callback(STag_surfxml_platform_cb_list, &init_data);
   surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_route);
   surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_loopback);
   surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_traces);