Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill all free_string functions declared locally to cleanup dynars afterward, and...
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 21 May 2008 14:58:52 +0000 (14:58 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 21 May 2008 14:58:52 +0000 (14:58 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5485 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/gras/DataDesc/cbps.c
src/include/surf/surf.h
src/surf/network.c
src/surf/network_constant.c
src/surf/network_gtnets.c
src/surf/surfxml_parse.c
src/surf/workstation_ptask_L07.c
src/xbt/dynar.c

index c3f7e4c..df1b055 100644 (file)
@@ -27,10 +27,6 @@ typedef struct s_gras_cbps {
   xbt_dynar_t globals;
 } s_gras_cbps_t;
 
-static void free_string(void *d){
-  free(*(void**)d);
-}
-
 gras_cbps_t gras_cbps_new(void) {
   gras_cbps_t  res;
 
index 16dd164..3210609 100644 (file)
@@ -575,7 +575,6 @@ XBT_PUBLIC(void) surf_exit(void);
 /* Prototypes of the functions that handle the properties */
 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);
-void free_string(void*);
 
 /* Prototypes for functions handling routing and were factorized succesfully from the models */
 void init_data(void);
index c2ed3ea..7c81c2f 100644 (file)
@@ -162,7 +162,7 @@ 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 *), &free_string);
+  route_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
 }
 
 static void parse_route_set_route(void)
@@ -217,6 +217,7 @@ static void add_route(void)
 
     src_id = strtol(xbt_dynar_get_as(keys, 0, char*), &end, 16);
     dst_id = strtol(xbt_dynar_get_as(keys, 1, char*), &end, 16);
+    xbt_dynar_free(&keys);
  
     xbt_dynar_foreach (links, cpt, link) {
       TRY {
index 36664cc..f961845 100644 (file)
@@ -59,7 +59,7 @@ 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 *), &free_string);
+  route_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
 }
 
 static void parse_route_set_route(void)
index a37cdac..66e8590 100644 (file)
@@ -223,7 +223,7 @@ static void parse_route_set_endpoints(void)
 /*  nb_link = 0;
   link_name = NULL;
 */
-  route_link_list = xbt_dynar_new(sizeof(char *), &free_string);
+  route_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
 }
 
 /* KF*/
index e2170ba..1b5c8fb 100644 (file)
@@ -229,6 +229,7 @@ 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);
 
@@ -480,11 +481,6 @@ void parse_properties(void)
    xbt_dict_set(current_property_set, A_surfxml_prop_id, value, free);
 }
 
-void free_string(void *d)
-{
-  free(*(void**)d);
-}
-
 void surfxml_add_callback(xbt_dynar_t cb_list, void_f_void_t function)
 {
   xbt_dynar_push(cb_list, &function);
@@ -755,7 +751,7 @@ void parse_route_multi_set_endpoints(void)
   is_symmetric_route = A_surfxml_route_c_multi_symmetric;
   route_multi_size++;
 
-  route_link_list = xbt_dynar_new(sizeof(char *), &free_string);
+  route_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
 }
 
 static int contains(xbt_dynar_t list, const char* value)
@@ -890,14 +886,14 @@ static void convert_route_multi_to_routes(void)
     dst_names = (xbt_dynar_t)xbt_dict_get_or_null(set_list, dst);
     /* Add to dynar even if they are simple names */
     if (src_names == NULL) {
-       src_names = xbt_dynar_new(sizeof(char *), &free_string);
+       src_names = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
        val = xbt_strdup(src);
        xbt_dynar_push(src_names, &val);
        if (strcmp(val,"$*") != 0 && NULL == xbt_dict_get_or_null(set, val))
          THROW3(unknown_error,0,"(In route:multi (%s -> %s) source %s does not exist (not a set or a host)", src, dst, src);
     }
     if (dst_names == NULL) {
-       dst_names = xbt_dynar_new(sizeof(char *), &free_string);
+       dst_names = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
        val = xbt_strdup(dst);
        if (strcmp(val,"$*") != 0 && NULL == xbt_dict_get_or_null(set, val))
          THROW3(unknown_error,0,"(In route:multi (%s -> %s) destination %s does not exist (not a set or a host)", src, dst, dst);
index b66945f..ec0c05e 100644 (file)
@@ -869,7 +869,7 @@ static void parse_route_set_endpoints(void)
 
   route_action = A_surfxml_route_action;
 
-  route_link_list = xbt_dynar_new(sizeof(char*), &free_string);
+  route_link_list = xbt_dynar_new(sizeof(char*), &xbt_free_ref);
 }
 
 static void parse_route_set_route(void)
index f29b280..ab89031 100644 (file)
@@ -1005,11 +1005,6 @@ XBT_TEST_UNIT("double",test_dynar_double,"Dynars of doubles") {
 
 /* doxygen_string_cruft */
 
-/* The function we will use to free the data */
-static void free_string(void *d){
-  free(*(void**)d);
-}
-
 /*******************************************************************************/
 /*******************************************************************************/
 /*******************************************************************************/
@@ -1021,7 +1016,7 @@ XBT_TEST_UNIT("string",test_dynar_string,"Dyars of strings") {
    char *s1,*s2;
    
    xbt_test_add0("==== Traverse the empty dynar");
-   d=xbt_dynar_new(sizeof(char *),&free_string);
+   d=xbt_dynar_new(sizeof(char *),&xbt_free_ref);
    xbt_dynar_foreach(d,iter,s1){
      xbt_test_assert0(FALSE,
                  "Damnit, there is something in the empty dynar");
@@ -1031,7 +1026,7 @@ XBT_TEST_UNIT("string",test_dynar_string,"Dyars of strings") {
 
    xbt_test_add1("==== Push %d strings, set them again 3 times, shift them",NB_ELEM);
    /* Populate_str [doxygen cruft] */
-   d=xbt_dynar_new(sizeof(char*),&free_string);
+   d=xbt_dynar_new(sizeof(char*),&xbt_free_ref);
    /* 1. Populate the dynar */
    for (cpt=0; cpt< NB_ELEM; cpt++) {
      sprintf(buf,"%d",cpt);
@@ -1066,7 +1061,7 @@ XBT_TEST_UNIT("string",test_dynar_string,"Dyars of strings") {
 
 
    xbt_test_add1("==== Unshift, traverse and pop %d strings",NB_ELEM);
-   d=xbt_dynar_new(sizeof(char**),&free_string);
+   d=xbt_dynar_new(sizeof(char**),&xbt_free_ref);
    for (cpt=0; cpt< NB_ELEM; cpt++) {
      sprintf(buf,"%d",cpt);
      s1=strdup(buf);
@@ -1094,7 +1089,7 @@ XBT_TEST_UNIT("string",test_dynar_string,"Dyars of strings") {
 
 
    xbt_test_add2("==== Push %d strings, insert %d strings in the middle, shift everything",NB_ELEM,NB_ELEM/5);
-   d=xbt_dynar_new(sizeof(char*),&free_string);
+   d=xbt_dynar_new(sizeof(char*),&xbt_free_ref);
    for (cpt=0; cpt< NB_ELEM; cpt++) {
      sprintf(buf,"%d",cpt);
      s1=strdup(buf);
@@ -1135,7 +1130,7 @@ XBT_TEST_UNIT("string",test_dynar_string,"Dyars of strings") {
 
 
    xbt_test_add3("==== Push %d strings, remove %d-%d. free the rest",NB_ELEM,2*(NB_ELEM/5),4*(NB_ELEM/5));
-   d=xbt_dynar_new(sizeof(char*),&free_string);
+   d=xbt_dynar_new(sizeof(char*),&xbt_free_ref);
    for (cpt=0; cpt< NB_ELEM; cpt++) {
      sprintf(buf,"%d",cpt);
      s1=strdup(buf);