Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix constness in parser
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 8 Nov 2011 12:43:27 +0000 (13:43 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 8 Nov 2011 12:43:27 +0000 (13:43 +0100)
src/include/surf/surfxml_parse_values.h
src/surf/surf_routing.c
src/surf/surfxml_parse.c

index bd2f1ab..afab4ba 100644 (file)
@@ -9,33 +9,33 @@
 
 typedef struct s_surf_parsing_peer_arg *surf_parsing_peer_arg_t;
 typedef struct s_surf_parsing_peer_arg {
-       char* id; //FIXME: convert to const char
-       char* power;//FIXME: convert to double
-       char* bw_in;
-       char* bw_out;
-       char* lat;
-       char* coord;
-       char* availability_trace;
-       char* state_trace;
+       const char* id;
+       const char* power;//FIXME: convert to double
+       const char* bw_in;
+       const char* bw_out;
+       const char* lat;
+       const char* coord;
+       const char* availability_trace;
+       const char* state_trace;
 } s_surf_parsing_peer_arg_t;
 
 typedef struct s_surf_parsing_cluster_arg *surf_parsing_cluster_arg_t;
 typedef struct s_surf_parsing_cluster_arg {
-       char* id;
-       char* prefix;
-       char* suffix;
-       char* radical;
+       const char* id;
+       const char* prefix;
+       const char* suffix;
+       const char* radical;
        double power;
        int core_amount;
        double bw;
        double lat;
        double bb_bw;
        double bb_lat;
-       char* router_id;
+       const char* router_id;
        int sharing_policy;
        int bb_sharing_policy;
-       char* availability_trace;
-       char* state_trace;
+       const char* availability_trace; //FIXME: convert to tmgr
+       const char* state_trace;
 } s_surf_parsing_cluster_arg_t;
 
 typedef struct s_surf_parsing_link_up_down *surf_parsing_link_up_down_t;
index 688b0fe..fc81aae 100644 (file)
@@ -1390,9 +1390,9 @@ void routing_parse_Scluster(void)
   {
          if(xbt_dict_size(patterns)==0)
                  patterns = xbt_dict_new();
-         xbt_dict_set(patterns,"id",struct_cluster->id,NULL);
-         xbt_dict_set(patterns,"prefix",struct_cluster->prefix,NULL);
-         xbt_dict_set(patterns,"suffix",struct_cluster->suffix,NULL);
+         xbt_dict_set(patterns,"id",xbt_strdup(struct_cluster->id),free);
+         xbt_dict_set(patterns,"prefix",xbt_strdup(struct_cluster->prefix),free);
+         xbt_dict_set(patterns,"suffix",xbt_strdup(struct_cluster->suffix),free);
   }
 
   unsigned int iter;
index a5ce2d9..950173c 100644 (file)
@@ -332,42 +332,30 @@ void STag_surfxml_cluster(void){
        struct_cluster->sharing_policy = AX_surfxml_cluster_sharing_policy;
        struct_cluster->bb_sharing_policy = AX_surfxml_cluster_bb_sharing_policy;
 
-       struct_cluster->availability_trace = xbt_strdup(A_surfxml_cluster_availability_file);
-       struct_cluster->state_trace = 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->router_id);
-       xbt_free(struct_cluster->availability_trace);
-       xbt_free(struct_cluster->state_trace);
        xbt_free(struct_cluster);
 }
 
 void STag_surfxml_peer(void){
        struct_peer = xbt_new0(s_surf_parsing_peer_arg_t, 1);
-       struct_peer->id = xbt_strdup(A_surfxml_peer_id);
-       struct_peer->power = xbt_strdup(A_surfxml_peer_power);
-       struct_peer->bw_in = xbt_strdup(A_surfxml_peer_bw_in);
-       struct_peer->bw_out = xbt_strdup(A_surfxml_peer_bw_out);
-       struct_peer->lat = xbt_strdup(A_surfxml_peer_lat);
-       struct_peer->coord = xbt_strdup(A_surfxml_peer_coordinates);
-       struct_peer->availability_trace = xbt_strdup(A_surfxml_peer_availability_file);
-       struct_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->id);
-       xbt_free(struct_peer->power);
-       xbt_free(struct_peer->bw_in);
-       xbt_free(struct_peer->bw_out);
-       xbt_free(struct_peer->lat);
-       xbt_free(struct_peer->coord);
-       xbt_free(struct_peer->availability_trace);
-       xbt_free(struct_peer->state_trace);
        xbt_free(struct_peer);
 }
 void STag_surfxml_link(void){