Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[SURF] NULL -> nullptr substitution
[simgrid.git] / src / surf / xml / surfxml_sax_cb.cpp
index a0d39b4..4a75fdb 100644 (file)
@@ -410,7 +410,7 @@ void STag_surfxml_host(void){
 
 void STag_surfxml_prop(void)
 {
-  if(AS_TAG){
+  if(AS_TAG){ // We need a stack here to retrieve the most recently opened AS
     if (!as_current_property_set){
       xbt_assert(as_prop_nb < 1024, "Number of AS property reach the limit!!!");
       as_current_property_set = xbt_dict_new_homogeneous(xbt_free_f); // Maybe, it should raise an error
@@ -462,8 +462,8 @@ void ETag_surfxml_host(void)    {
 
   XBT_DEBUG("pstate: %s", A_surfxml_host_pstate);
   host.core_amount = surf_parse_get_int(A_surfxml_host_core);
-  host.speed_trace = A_surfxml_host_availability___file[0] ? tmgr_trace_new_from_file(A_surfxml_host_availability___file) : NULL;
-  host.state_trace = A_surfxml_host_state___file[0] ? tmgr_trace_new_from_file(A_surfxml_host_state___file) : NULL;
+  host.speed_trace = A_surfxml_host_availability___file[0] ? tmgr_trace_new_from_file(A_surfxml_host_availability___file) : nullptr;
+  host.state_trace = A_surfxml_host_state___file[0] ? tmgr_trace_new_from_file(A_surfxml_host_state___file) : nullptr;
   host.pstate      = surf_parse_get_int(A_surfxml_host_pstate);
   host.coord       = A_surfxml_host_coordinates;
 
@@ -563,8 +563,6 @@ void ETag_surfxml_cluster(void){
     break;
   }
 
-  cluster.availability_trace = A_surfxml_cluster_availability___file;
-  cluster.state_trace = A_surfxml_cluster_state___file;
   sg_platf_new_cluster(&cluster);
 
   current_property_set = nullptr;
@@ -600,8 +598,8 @@ void STag_surfxml_peer(void){
   peer.bw_out             = surf_parse_get_bandwidth(A_surfxml_peer_bw___out, "bw_out of peer", peer.id);
   peer.lat                = surf_parse_get_time(A_surfxml_peer_lat, "lat of peer", peer.id);
   peer.coord              = A_surfxml_peer_coordinates;
-  peer.availability_trace = A_surfxml_peer_availability___file[0] ? tmgr_trace_new_from_file(A_surfxml_peer_availability___file) : NULL;
-  peer.state_trace        = A_surfxml_peer_state___file[0] ? tmgr_trace_new_from_file(A_surfxml_peer_state___file) : NULL;
+  peer.availability_trace = A_surfxml_peer_availability___file[0] ? tmgr_trace_new_from_file(A_surfxml_peer_availability___file) : nullptr;
+  peer.state_trace        = A_surfxml_peer_state___file[0] ? tmgr_trace_new_from_file(A_surfxml_peer_state___file) : nullptr;
 
   sg_platf_new_peer(&peer);
 }
@@ -618,10 +616,10 @@ void ETag_surfxml_link(void){
   link.properties          = current_property_set;
   link.id                  = A_surfxml_link_id;
   link.bandwidth           = surf_parse_get_bandwidth(A_surfxml_link_bandwidth, "bandwidth of link", link.id);
-  link.bandwidth_trace     = A_surfxml_link_bandwidth___file[0] ? tmgr_trace_new_from_file(A_surfxml_link_bandwidth___file) : NULL;
+  link.bandwidth_trace     = A_surfxml_link_bandwidth___file[0] ? tmgr_trace_new_from_file(A_surfxml_link_bandwidth___file) : nullptr;
   link.latency             = surf_parse_get_time(A_surfxml_link_latency, "latency of link", link.id);
-  link.latency_trace       = A_surfxml_link_latency___file[0] ? tmgr_trace_new_from_file(A_surfxml_link_latency___file) : NULL;
-  link.state_trace         = A_surfxml_link_state___file[0] ? tmgr_trace_new_from_file(A_surfxml_link_state___file):NULL;
+  link.latency_trace       = A_surfxml_link_latency___file[0] ? tmgr_trace_new_from_file(A_surfxml_link_latency___file) : nullptr;
+  link.state_trace         = A_surfxml_link_state___file[0] ? tmgr_trace_new_from_file(A_surfxml_link_state___file):nullptr;
 
   switch (A_surfxml_link_sharing___policy) {
   case A_surfxml_link_sharing___policy_SHARED:
@@ -741,6 +739,7 @@ void ETag_surfxml_route(void){
   }
 
   sg_platf_new_route(&route);
+  delete route.link_list;
   xbt_dynar_free(&parsed_link_list);
 }
 
@@ -782,6 +781,7 @@ void ETag_surfxml_ASroute(void){
   }
 
   sg_platf_new_route(&ASroute);
+  delete ASroute.link_list;
 }
 
 void ETag_surfxml_bypassRoute(void){
@@ -884,13 +884,10 @@ void ETag_surfxml_AS(void){
     xbt_dict_t dict = (xbt_dict_t) as_dict_tab[as_prop_nb-1];
     as_prop_nb--;
     XBT_DEBUG("POP prop %p for AS '%s'",dict,name);
-    xbt_lib_set(as_router_lib,
-        name,
-      ROUTING_PROP_ASR_LEVEL,
-      dict);
+    xbt_lib_set(as_router_lib, name, ROUTING_PROP_ASR_LEVEL, dict);
     xbt_free(name);
   }
-  sg_platf_new_AS_end();
+  sg_platf_new_AS_seal();
 }
 
 void STag_surfxml_config(void){
@@ -908,8 +905,8 @@ void ETag_surfxml_config(void){
   char *cfg;
   xbt_dict_foreach(current_property_set, cursor, key, elem) {
     cfg = bprintf("%s:%s",key,elem);
-    if(xbt_cfg_is_default_value(_sg_cfg_set, key))
-      xbt_cfg_set_parse(_sg_cfg_set, cfg);
+    if(xbt_cfg_is_default_value(key))
+      xbt_cfg_set_parse(cfg);
     else
       XBT_INFO("The custom configuration '%s' is already defined by user!",key);
     free(cfg);
@@ -954,6 +951,12 @@ void ETag_surfxml_process(void){
   }
 
   sg_platf_new_process(&process);
+
+  for (int i = 0; i != argc; ++i)
+    xbt_free(argv[i]);
+  xbt_free(argv);
+  argv = nullptr;
+
   current_property_set = nullptr;
 }
 
@@ -989,7 +992,7 @@ void ETag_surfxml_model___prop(void){}
 
 void surf_parse_open(const char *file)
 {
-  xbt_assert(file, "Cannot parse the NULL file. Bypassing the parser is strongly deprecated nowadays.");
+  xbt_assert(file, "Cannot parse the nullptr file. Bypassing the parser is strongly deprecated nowadays.");
 
   if (!surf_input_buffer_stack)
     surf_input_buffer_stack = xbt_dynar_new(sizeof(YY_BUFFER_STATE), nullptr);