From: Martin Quinson Date: Tue, 8 Nov 2011 12:43:27 +0000 (+0100) Subject: fix constness in parser X-Git-Tag: exp_20120216~431 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/33532af6f3b6db5d3b05062cddb1063b8c08a234 fix constness in parser --- diff --git a/src/include/surf/surfxml_parse_values.h b/src/include/surf/surfxml_parse_values.h index bd2f1ab0bb..afab4baba3 100644 --- a/src/include/surf/surfxml_parse_values.h +++ b/src/include/surf/surfxml_parse_values.h @@ -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; diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 688b0feef8..fc81aaed1d 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -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; diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index a5ce2d9c63..950173c99b 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -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){