Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[From Arnaud Giersch] Fix memory leak when MSG_create_environment() or
authornavarrop <navarrop@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 6 Jul 2010 14:06:51 +0000 (14:06 +0000)
committernavarrop <navarrop@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 6 Jul 2010 14:06:51 +0000 (14:06 +0000)
MSG_launch_application() fail.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7979 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/simix/smx_deployment.c
src/surf/surfxml_parse.c

index 5bc2681..31cd8fd 100644 (file)
@@ -119,6 +119,7 @@ static void parse_process_finalize(void)
  */
 void SIMIX_launch_application(const char *file)
 {
+  int parse_status;
   xbt_assert0(simix_global,
               "SIMIX_global_init has to be called before SIMIX_launch_application.");
   surf_parse_reset_parser();
@@ -128,8 +129,9 @@ void SIMIX_launch_application(const char *file)
   surfxml_add_callback(ETag_surfxml_process_cb_list, parse_process_finalize);
 
   surf_parse_open(file);
-  xbt_assert1((!surf_parse()), "Parse error in %s", file);
+  parse_status = surf_parse();
   surf_parse_close();
+  xbt_assert1(!parse_status, "Parse error in %s", file);
 }
 
 /**
index f312e78..7ff2efa 100644 (file)
@@ -437,13 +437,14 @@ void surf_parse_open(const char *file)
     }
     return;
   }
+  surf_file_to_parse = surf_fopen(file, "r");
+  xbt_assert1((surf_file_to_parse), "Unable to open \"%s\"\n", file);
+
   if (!surf_input_buffer_stack)
     surf_input_buffer_stack = xbt_dynar_new(sizeof(YY_BUFFER_STATE), NULL);
   if (!surf_file_to_parse_stack)
     surf_file_to_parse_stack = xbt_dynar_new(sizeof(FILE *), NULL);
 
-  surf_file_to_parse = surf_fopen(file, "r");
-  xbt_assert1((surf_file_to_parse), "Unable to open \"%s\"\n", file);
   surf_input_buffer = surf_parse__create_buffer(surf_file_to_parse, 10);
   surf_parse__switch_to_buffer(surf_input_buffer);
   surf_parse_lineno = 1;
@@ -608,11 +609,15 @@ static void free_data(void)
 
 void parse_platform_file(const char *file)
 {
+  int parse_status;
   surf_parse_open(file);
   init_data();
-  xbt_assert1((!(*surf_parse) ()), "Parse error in %s", file);
+  parse_status = surf_parse();
   free_data();
   surf_parse_close();
+  if (parse_status)
+    xbt_dict_free(&random_data_list);
+  xbt_assert1(!parse_status, "Parse error in %s", file);
 }
 
 /* Functions to bypass route tag. Used by the route:multi tag */