Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
plug a memleak when the cluster's router_id is not given
[simgrid.git] / src / surf / surfxml_parse.c
index 48cbb04..915dfd7 100644 (file)
@@ -309,65 +309,47 @@ void STag_surfxml_router(void){
 
 void STag_surfxml_cluster(void){
        struct_cluster = xbt_new0(s_surf_parsing_cluster_arg_t, 1);
-       struct_cluster->V_cluster_id = A_surfxml_cluster_id;
-       struct_cluster->V_cluster_prefix = A_surfxml_cluster_prefix;
-       struct_cluster->V_cluster_suffix = A_surfxml_cluster_suffix;
-       struct_cluster->V_cluster_radical = A_surfxml_cluster_radical;
-       struct_cluster->S_cluster_power= surf_parse_get_double(A_surfxml_cluster_power);
-       struct_cluster->S_cluster_core = surf_parse_get_int(A_surfxml_cluster_core);
-       struct_cluster->S_cluster_bw =   surf_parse_get_double(A_surfxml_cluster_bw);
-       struct_cluster->S_cluster_lat =  surf_parse_get_double(A_surfxml_cluster_lat);
+       struct_cluster->id = A_surfxml_cluster_id;
+       struct_cluster->prefix = A_surfxml_cluster_prefix;
+       struct_cluster->suffix = A_surfxml_cluster_suffix;
+       struct_cluster->radical = A_surfxml_cluster_radical;
+       struct_cluster->power= surf_parse_get_double(A_surfxml_cluster_power);
+       struct_cluster->core_amount = surf_parse_get_int(A_surfxml_cluster_core);
+       struct_cluster->bw =   surf_parse_get_double(A_surfxml_cluster_bw);
+       struct_cluster->lat =  surf_parse_get_double(A_surfxml_cluster_lat);
        if(strcmp(A_surfxml_cluster_bb_bw,""))
-         struct_cluster->S_cluster_bb_bw = surf_parse_get_double(A_surfxml_cluster_bb_bw);
+         struct_cluster->bb_bw = surf_parse_get_double(A_surfxml_cluster_bb_bw);
        if(strcmp(A_surfxml_cluster_bb_lat,""))
-         struct_cluster->S_cluster_bb_lat = surf_parse_get_double(A_surfxml_cluster_bb_lat);
-       if(!strcmp(A_surfxml_cluster_router_id,""))
-               struct_cluster->S_cluster_router_id = bprintf("%s%s_router%s",
-                               struct_cluster->V_cluster_prefix,
-                               struct_cluster->V_cluster_id,
-                               struct_cluster->V_cluster_suffix);
-       else
-               struct_cluster->S_cluster_router_id = A_surfxml_cluster_router_id;
+         struct_cluster->bb_lat = surf_parse_get_double(A_surfxml_cluster_bb_lat);
+       struct_cluster->router_id = A_surfxml_cluster_router_id;
 
-       struct_cluster->V_cluster_sharing_policy = AX_surfxml_cluster_sharing_policy;
-       struct_cluster->V_cluster_bb_sharing_policy = AX_surfxml_cluster_bb_sharing_policy;
+       struct_cluster->sharing_policy = AX_surfxml_cluster_sharing_policy;
+       struct_cluster->bb_sharing_policy = AX_surfxml_cluster_bb_sharing_policy;
 
-       struct_cluster->V_cluster_availability_file = xbt_strdup(A_surfxml_cluster_availability_file);
-       struct_cluster->V_cluster_state_file = xbt_strdup(A_surfxml_cluster_state_file);
+       struct_cluster->availability_trace = A_surfxml_cluster_availability_file;
+       struct_cluster->state_trace = A_surfxml_cluster_state_file;
 
        surfxml_call_cb_functions(STag_surfxml_cluster_cb_list);
 }
 void ETag_surfxml_cluster(void){
        surfxml_call_cb_functions(ETag_surfxml_cluster_cb_list);
-       if( !strcmp(A_surfxml_cluster_router_id,""))
-                       xbt_free(struct_cluster->S_cluster_router_id);
-       xbt_free(struct_cluster->V_cluster_availability_file);
-       xbt_free(struct_cluster->V_cluster_state_file);
        xbt_free(struct_cluster);
 }
 
 void STag_surfxml_peer(void){
        struct_peer = xbt_new0(s_surf_parsing_peer_arg_t, 1);
-       struct_peer->V_peer_id = xbt_strdup(A_surfxml_peer_id);
-       struct_peer->V_peer_power = xbt_strdup(A_surfxml_peer_power);
-       struct_peer->V_peer_bw_in = xbt_strdup(A_surfxml_peer_bw_in);
-       struct_peer->V_peer_bw_out = xbt_strdup(A_surfxml_peer_bw_out);
-       struct_peer->V_peer_lat = xbt_strdup(A_surfxml_peer_lat);
-       struct_peer->V_peer_coord = xbt_strdup(A_surfxml_peer_coordinates);
-       struct_peer->V_peer_availability_trace = xbt_strdup(A_surfxml_peer_availability_file);
-       struct_peer->V_peer_state_trace = xbt_strdup(A_surfxml_peer_state_file);
+       struct_peer->id = A_surfxml_peer_id;
+       struct_peer->power = A_surfxml_peer_power;
+       struct_peer->bw_in = A_surfxml_peer_bw_in;
+       struct_peer->bw_out = A_surfxml_peer_bw_out;
+       struct_peer->lat = A_surfxml_peer_lat;
+       struct_peer->coord = A_surfxml_peer_coordinates;
+       struct_peer->availability_trace = A_surfxml_peer_availability_file;
+       struct_peer->state_trace = A_surfxml_peer_state_file;
        surfxml_call_cb_functions(STag_surfxml_peer_cb_list);
 }
 void ETag_surfxml_peer(void){
        surfxml_call_cb_functions(ETag_surfxml_peer_cb_list);
-       xbt_free(struct_peer->V_peer_id);
-       xbt_free(struct_peer->V_peer_power);
-       xbt_free(struct_peer->V_peer_bw_in);
-       xbt_free(struct_peer->V_peer_bw_out);
-       xbt_free(struct_peer->V_peer_lat);
-       xbt_free(struct_peer->V_peer_coord);
-       xbt_free(struct_peer->V_peer_availability_trace);
-       xbt_free(struct_peer->V_peer_state_trace);
        xbt_free(struct_peer);
 }
 void STag_surfxml_link(void){
@@ -377,28 +359,36 @@ void STag_surfxml_link(void){
   xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)");
   link.properties = current_property_set = xbt_dict_new();
 
-       link.V_link_id = A_surfxml_link_id;
-       link.V_link_bandwidth = surf_parse_get_double(A_surfxml_link_bandwidth);
-       link.V_link_bandwidth_file = tmgr_trace_new(A_surfxml_link_bandwidth_file);
-       link.V_link_latency = surf_parse_get_double(A_surfxml_link_latency);
-       link.V_link_latency_file = tmgr_trace_new(A_surfxml_link_latency_file);
-       xbt_assert((A_surfxml_link_state == A_surfxml_link_state_ON) ||
-                         (A_surfxml_link_state == A_surfxml_link_state_OFF), "Invalid state");
-       if (A_surfxml_link_state == A_surfxml_link_state_ON)
-               link.V_link_state = SURF_RESOURCE_ON;
-       if (A_surfxml_link_state == A_surfxml_link_state_OFF)
-               link.V_link_state = SURF_RESOURCE_OFF;
-       link.V_link_state_file = tmgr_trace_new(A_surfxml_link_state_file);
-       link.V_link_sharing_policy = A_surfxml_link_sharing_policy;
-
-       if (A_surfxml_link_sharing_policy == A_surfxml_link_sharing_policy_SHARED)
-               link.V_policy_initial_link = SURF_LINK_SHARED;
-       else
-       {
-        if (A_surfxml_link_sharing_policy == A_surfxml_link_sharing_policy_FATPIPE)
-                link.V_policy_initial_link = SURF_LINK_FATPIPE;
-        else if (A_surfxml_link_sharing_policy == A_surfxml_link_sharing_policy_FULLDUPLEX)
-                link.V_policy_initial_link = SURF_LINK_FULLDUPLEX;
+       link.id = A_surfxml_link_id;
+       link.bandwidth = surf_parse_get_double(A_surfxml_link_bandwidth);
+       link.bandwidth_trace = tmgr_trace_new(A_surfxml_link_bandwidth_file);
+       link.latency = surf_parse_get_double(A_surfxml_link_latency);
+       link.latency_trace = tmgr_trace_new(A_surfxml_link_latency_file);
+
+       switch (A_surfxml_link_state) {
+       case A_surfxml_link_state_ON:
+               link.state = SURF_RESOURCE_ON;
+               break;
+       case A_surfxml_link_state_OFF:
+               link.state = SURF_RESOURCE_OFF;
+               break;
+       default:
+         surf_parse_error(bprintf("invalid state for link %s",link.id));
+       }
+       link.state_trace = tmgr_trace_new(A_surfxml_link_state_file);
+
+       switch (A_surfxml_link_sharing_policy) {
+       case A_surfxml_link_sharing_policy_SHARED:
+               link.policy = SURF_LINK_SHARED;
+               break;
+       case A_surfxml_link_sharing_policy_FATPIPE:
+                link.policy = SURF_LINK_FATPIPE;
+                break;
+       case A_surfxml_link_sharing_policy_FULLDUPLEX:
+                link.policy = SURF_LINK_FULLDUPLEX;
+                break;
+       default:
+         surf_parse_error(bprintf("Invalid sharing policy in link %s",link.id));
        }
 
        sg_platf_new_link(&link);