Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix memleak
[simgrid.git] / src / surf / cpu_cas01.cpp
index 2cca94a..8bc8545 100644 (file)
@@ -15,9 +15,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu_cas, surf_cpu,
                                 "Logging specific to the SURF CPU IMPROVED module");
 }
 
-static xbt_swag_t
-    cpu_running_action_set_that_does_not_need_being_checked = NULL;
-
 /*************
  * CallBacks *
  *************/
@@ -84,7 +81,7 @@ CpuCas01Model::CpuCas01Model() : CpuModel("cpu")
     xbt_die("Unsupported optimization (%s) for this model", optim);
   }
 
-  cpu_running_action_set_that_does_not_need_being_checked =
+  p_cpuRunningActionSetThatDoesNotNeedBeingChecked =
       xbt_swag_new(xbt_swag_offset(*action, p_stateHookup));
 
   if (p_updateMechanism == UM_LAZY) {
@@ -120,8 +117,7 @@ CpuCas01Model::~CpuCas01Model()
 
   surf_cpu_model_pm = NULL;
 
-  xbt_swag_free(cpu_running_action_set_that_does_not_need_being_checked);
-  cpu_running_action_set_that_does_not_need_being_checked = NULL;
+  xbt_swag_free(p_cpuRunningActionSetThatDoesNotNeedBeingChecked);
 }
 
 void CpuCas01Model::parseInit(sg_platf_host_cbarg_t host)
@@ -157,7 +153,7 @@ CpuCas01LmmPtr CpuCas01Model::createResource(const char *name, xbt_dynar_t power
   return (CpuCas01LmmPtr) xbt_lib_get_elm_or_null(host_lib, name);
 }
 
-double CpuCas01Model::shareResourcesFull(double now)
+double CpuCas01Model::shareResourcesFull(double /*now*/)
 {
   return Model::shareResourcesMaxMin(p_runningActionSet,
                              p_maxminSystem, lmm_solve);
@@ -200,10 +196,11 @@ void CpuCas01Model::addTraces()
  * Resource *
  ************/
 CpuCas01Lmm::CpuCas01Lmm(CpuCas01ModelPtr model, const char *name, xbt_dynar_t powerPeak,
-               int pstate, double powerScale, tmgr_trace_t powerTrace, int core,
-        e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
-       xbt_dict_t properties) :
-       CpuLmm(model, name, properties), Resource(model, name, properties) {
+                         int pstate, double powerScale, tmgr_trace_t powerTrace, int core,
+                         e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
+                         xbt_dict_t properties) :
+       Resource(model, name, properties), CpuLmm(model, name, properties) {
+  p_powerEvent = NULL;
   m_powerPeak = xbt_dynar_get_as(powerPeak, pstate, double);
   p_powerPeakList = powerPeak;
   m_pstate = pstate;
@@ -235,7 +232,6 @@ CpuCas01Lmm::~CpuCas01Lmm(){
   xbt_dynar_free(&p_energy->power_range_watts_list);
   xbt_dynar_free(&p_powerPeakList);
   xbt_free(p_energy);
-  return;
 }
 
 bool CpuCas01Lmm::isUsed()
@@ -338,7 +334,7 @@ ActionPtr CpuCas01Lmm::sleep(double duration)
     /* Move to the *end* of the corresponding action set. This convention
        is used to speed up update_resource_state  */
     xbt_swag_remove(static_cast<ActionPtr>(action), action->p_stateSet);
-    action->p_stateSet = cpu_running_action_set_that_does_not_need_being_checked;
+    action->p_stateSet = static_cast<CpuCas01ModelPtr>(p_model)->p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
     xbt_swag_insert(static_cast<ActionPtr>(action), action->p_stateSet);
   }
 
@@ -463,7 +459,7 @@ double CpuCas01Lmm::getCurrentPowerPeak()
 double CpuCas01Lmm::getPowerPeakAt(int pstate_index)
 {
   xbt_dynar_t plist = p_powerPeakList;
-  xbt_assert((pstate_index <= xbt_dynar_length(plist)), "Invalid parameters (pstate index out of bounds)");
+  xbt_assert((pstate_index <= (int)xbt_dynar_length(plist)), "Invalid parameters (pstate index out of bounds)");
 
   return xbt_dynar_get_as(plist, pstate_index, double);
 }
@@ -476,7 +472,7 @@ int CpuCas01Lmm::getNbPstates()
 void CpuCas01Lmm::setPowerPeakAt(int pstate_index)
 {
   xbt_dynar_t plist = p_powerPeakList;
-  xbt_assert((pstate_index <= xbt_dynar_length(plist)), "Invalid parameters (pstate index out of bounds)");
+  xbt_assert((pstate_index <= (int)xbt_dynar_length(plist)), "Invalid parameters (pstate index out of bounds)");
 
   double new_power_peak = xbt_dynar_get_as(plist, pstate_index, double);
   m_pstate = pstate_index;