Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
protect against multiply create hosts in one location only
[simgrid.git] / src / surf / cpu_ti.cpp
index 9052b30..b2242fa 100644 (file)
@@ -381,7 +381,6 @@ int CpuTiTrace::binarySearch(double *array, double a, int low, int high)
 
 static void cpu_ti_define_callbacks()
 {
-  sg_platf_host_add_cb(cpu_parse_init);
   sg_platf_postparse_add_cb(cpu_add_traces);
 }
 
@@ -435,16 +434,11 @@ Cpu *CpuTiModel::createCpu(const char *name,
 {
   xbt_assert(core==1,"Multi-core not handled with this model yet");
   sg_host_t host = sg_host_by_name(name);
-  xbt_assert(!sg_host_surfcpu(host),
-              "Host '%s' declared several times in the platform file",
-              name);
   xbt_assert(xbt_dynar_getfirst_as(powerPeak, double) > 0.0,
       "Power has to be >0.0. Did you forget to specify the mandatory power attribute?");
   CpuTi *cpu = new CpuTi(this, name, powerPeak, pstate, powerScale, powerTrace,
                           core, stateInitial, stateTrace, cpuProperties);
-  surf_callback_emit(cpuCreatedCallbacks, cpu);
-  surf_callback_emit(cpuStateChangedCallbacks, cpu, SURF_RESOURCE_ON, stateInitial);
-  sg_host_surfcpu_set(host, cpu);
+  sg_host_surfcpu_register(host, cpu);
   return cpu;
 }
 
@@ -564,7 +558,6 @@ CpuTi::CpuTi(CpuTiModel *model, const char *name, xbt_dynar_t powerPeak,
   m_lastUpdate = 0;
 
   xbt_dynar_get_cpy(powerPeak, 0, &m_powerPeak);
-  xbt_dynar_free(&powerPeak);  /* kill memory leak */
   XBT_DEBUG("CPU create: peak=%f", m_powerPeak);
 
   if (stateTrace)