Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
getting rid of memleaks.
authoralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 30 Aug 2005 21:35:03 +0000 (21:35 +0000)
committeralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 30 Aug 2005 21:35:03 +0000 (21:35 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@1677 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/msg/global.c
src/msg/msg_config.c
src/msg/private.h
src/surf/surf_timer.c
src/xbt/context.c

index 6bf0f87..7e68c31 100644 (file)
@@ -514,6 +514,7 @@ MSG_error_t MSG_clean(void)
     fclose(msg_global->paje_output);
     msg_global->paje_output = NULL;
   }
+  msg_config_finalize();
   free(msg_global);
   surf_exit();
 
index f7cd094..50cb176 100644 (file)
@@ -50,6 +50,15 @@ void msg_config_init(void) {
   xbt_cfg_set_string(_msg_cfg_set,"surf_workstation_model", "CLM03");
 }
 
+void msg_config_finalize(void) {
+
+  if (!_msg_init_status) 
+    return; /* Not initialized yet. Nothing to do */
+
+  xbt_cfg_free(&_msg_cfg_set);
+  _msg_init_status = 0;
+}
+
 /** \brief set a configuration variable
  * 
  * Currently existing configuation variable:
index 559d774..01be636 100644 (file)
@@ -93,6 +93,7 @@ extern MSG_Global_t msg_global;
       
 /************************** Configuration support ********************************/
 void msg_config_init(void); /* create the config set, call this before use! */
+void msg_config_finalize(void); /* destroy the config set, call this at cleanup. */
 extern int _msg_init_status; /* 0: beginning of time; 
                                 1: pre-inited (cfg_set created); 
                                 2: inited (running) */
index 35ddfa8..678af82 100644 (file)
@@ -159,6 +159,9 @@ static int action_is_suspended(surf_action_t action)
 
 static void finalize(void)
 {
+  tmgr_trace_free(empty_trace);
+  empty_trace = NULL;
+
   xbt_swag_free(command_pending);
   xbt_swag_free(command_to_run);
 
index 0d3f587..e67c2ce 100644 (file)
@@ -99,6 +99,7 @@ static void xbt_context_destroy(xbt_context_t context)
   pthread_mutex_destroy(&(context->mutex));
   pthread_cond_destroy(&(context->cond));
 #endif
+  if(context->exception) free(context->exception);
   free(context);
   return;
 }
@@ -320,7 +321,6 @@ void xbt_context_free(xbt_context_t context)
   for(i=0;i<context->argc; i++) 
     if(context->argv[i]) free(context->argv[i]);
   if(context->argv) free(context->argv);
-  if(context->exception) free(context->exception);
   
   if(context->cleanup_func)
     context->cleanup_func(context->cleanup_arg);