Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix memleak
authorPaul Bédaride <paul.bedaride@gmail.com>
Thu, 28 Nov 2013 15:02:19 +0000 (16:02 +0100)
committerPaul Bédaride <paul.bedaride@gmail.com>
Thu, 28 Nov 2013 15:02:19 +0000 (16:02 +0100)
src/surf/cpu.cpp
src/surf/cpu.hpp
src/surf/surf.hpp

index 77f06e3..0c9a2f3 100644 (file)
@@ -137,23 +137,23 @@ CpuLmm::CpuLmm(CpuModelPtr model, const char* name, xbt_dict_t properties, int c
     xbt_assert(model == surf_cpu_model_pm);
 
   p_constraintCore = xbt_new(lmm_constraint_t, core);
+  p_constraintCoreId = xbt_new(void*, core);
 
   int i;
   for (i = 0; i < core; i++) {
     /* just for a unique id, never used as a string. */
-    void *cnst_id = bprintf("%s:%i", name, i);
-    p_constraintCore[i] = lmm_constraint_new(p_model->p_maxminSystem, cnst_id, m_powerScale * m_powerPeak);
+    p_constraintCoreId[i] = bprintf("%s:%i", name, i);
+    p_constraintCore[i] = lmm_constraint_new(p_model->p_maxminSystem, p_constraintCoreId[i], m_powerScale * m_powerPeak);
   }
 }
 
 CpuLmm::~CpuLmm(){
   if (p_constraintCore){
     for (int i = 0; i < m_core; i++) {
-         void *cnst_id = p_constraintCore[i]->id;
-         //FIXME:lmm_constraint_free(p_model->p_maxminSystem, p_constraintCore[i]);
-         xbt_free(cnst_id);
+         xbt_free(p_constraintCoreId[i]);
     }
     xbt_free(p_constraintCore);
+    xbt_free(p_constraintCoreId);
   }
 }
 
index e4a5646..b60bf13 100644 (file)
@@ -68,11 +68,13 @@ protected:
 
 class CpuLmm : public ResourceLmm, public Cpu {
 public:
-  CpuLmm() : p_constraintCore(NULL) {};
+  CpuLmm() : p_constraintCore(NULL), p_constraintCoreId(NULL) {};
   CpuLmm(CpuModelPtr model, const char* name, xbt_dict_t properties, int core, double powerPeak, double powerScale);
   ~CpuLmm();
   /* Note (hypervisor): */
   lmm_constraint_t *p_constraintCore;
+  void **p_constraintCoreId;
+
 };
 
 /**********
index 7a6b91b..8415040 100644 (file)
@@ -279,7 +279,6 @@ protected:
   int    m_refcount;
 #ifdef HAVE_TRACING
 #endif
-  //FIXME:removee_UM_t p_updateMechanism;
 
 private:
   int resourceUsed(void *resource_id);