Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
let lmm_system_free(nullptr) be a noop
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 26 Mar 2016 11:06:38 +0000 (12:06 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 26 Mar 2016 11:06:38 +0000 (12:06 +0100)
src/surf/maxmin.cpp
src/surf/network_interface.hpp
src/surf/storage_interface.cpp

index 978745f..e40a1ab 100644 (file)
@@ -115,15 +115,16 @@ lmm_system_t lmm_system_new(int selective_update)
 
 void lmm_system_free(lmm_system_t sys)
 {
 
 void lmm_system_free(lmm_system_t sys)
 {
-  lmm_variable_t var = NULL;
-  lmm_constraint_t cnst = NULL;
+  lmm_variable_t var = nullptr;
+  lmm_constraint_t cnst = nullptr;
+
+  if (!sys)
+    return;
 
 
-  
   while ((var = (lmm_variable_t) extract_variable(sys))) {
     XBT_WARN("Variable %d still in system when freing it: this may be a bug", var->id_int);
     lmm_var_free(sys, var);
   }
   while ((var = (lmm_variable_t) extract_variable(sys))) {
     XBT_WARN("Variable %d still in system when freing it: this may be a bug", var->id_int);
     lmm_var_free(sys, var);
   }
-
   while ((cnst = (lmm_constraint_t) extract_constraint(sys)))
     lmm_cnst_free(sys, cnst);
 
   while ((cnst = (lmm_constraint_t) extract_constraint(sys)))
     lmm_cnst_free(sys, cnst);
 
index 8362e85..a46e10b 100644 (file)
@@ -64,8 +64,7 @@ namespace simgrid {
 
       /** @brief Destructor */
       ~NetworkModel() {
 
       /** @brief Destructor */
       ~NetworkModel() {
-        if (maxminSystem_)
-          lmm_system_free(maxminSystem_);
+        lmm_system_free(maxminSystem_);
         xbt_heap_free(actionHeap_);
         delete modifiedSet_;
       }
         xbt_heap_free(actionHeap_);
         delete modifiedSet_;
       }
index cf639a3..c674ff9 100644 (file)
@@ -44,9 +44,7 @@ StorageModel::StorageModel()
 
 StorageModel::~StorageModel(){
   lmm_system_free(maxminSystem_);
 
 StorageModel::~StorageModel(){
   lmm_system_free(maxminSystem_);
-
   surf_storage_model = NULL;
   surf_storage_model = NULL;
-
   xbt_dynar_free(&p_storageList);
 }
 
   xbt_dynar_free(&p_storageList);
 }