bob.power_peak = xbt_dynar_new(sizeof(double), NULL);
xbt_dynar_push_as(bob.power_peak, double, 98095000.0);
sg_platf_new_host(&bob);
+ xbt_dynar_free(&bob.power_peak);
s_sg_platf_host_cbarg_t alice = SG_PLATF_HOST_INITIALIZER;
alice.id = "alice";
alice.power_peak = xbt_dynar_new(sizeof(double), NULL);
xbt_dynar_push_as(alice.power_peak, double, 98095000.0);
sg_platf_new_host(&alice);
+ xbt_dynar_free(&alice.power_peak);
s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
link.id = "link1";
long l = xbt_dynar_length(power_peak);
jpower_peak = jenv->NewDoubleArray(l);
- double *lout = (double *)xbt_dynar_to_array(power_peak);
+ double *lout = (double *) xbt_dynar_get_ptr(power_peak, 0);
jenv->SetDoubleArrayRegion(jpower_peak, 0, l, (jdouble*)lout);
- free(lout);
jpstate = (jint) pstate;
jpower_scale = (jdouble) power_scale;
lua_pop(L, 1);
sg_platf_new_host(&host);
+ xbt_dynar_free(&host.power_peak);
return 0;
}
core, xbt_dynar_get_as(powerPeak, pstate, double), powerScale,
stateInitial) {
p_powerEvent = NULL;
- p_powerPeakList = powerPeak;
+
+ // Copy the power peak array:
+ p_powerPeakList = xbt_dynar_new(sizeof(double), nullptr);
+ unsigned long n = xbt_dynar_length(powerPeak);
+ for (unsigned long i = 0; i != n; ++i) {
+ double value = xbt_dynar_get_as(powerPeak, i, double);
+ xbt_dynar_push(p_powerPeakList, &value);
+ }
+
m_pstate = pstate;
XBT_DEBUG("CPU create: peak=%f, pstate=%d", m_powerPeak, m_pstate);
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)
xbt_dict_t cpu_properties)
{
double power_initial = xbt_dynar_get_as(powerPeak, pstate, double);
- xbt_dynar_free(&powerPeak); // kill memory leak
sg_host_t sg_host = sg_host_by_name(name);
xbt_assert(!surf_host_resource_priv(sg_host),
link_id = bprintf("link_%s%d%s",cabinet->prefix,i,cabinet->suffix);
host.id = host_id;
link.id = link_id;
- xbt_dynar_t power_state_list = xbt_dynar_new(sizeof(double), NULL);
- xbt_dynar_push(power_state_list,&cabinet->power);
- host.power_peak = power_state_list;
+ host.power_peak = xbt_dynar_new(sizeof(double), NULL);
+ xbt_dynar_push(host.power_peak,&cabinet->power);
sg_platf_new_host(&host);
+ xbt_dynar_free(&host.power_peak);
sg_platf_new_link(&link);
char* link_up = bprintf("%s_UP",link_id);
XBT_DEBUG("\tstate_file=\"\"");
}
- xbt_dynar_t power_state_list = xbt_dynar_new(sizeof(double), NULL);
- xbt_dynar_push(power_state_list,&cluster->power);
- host.power_peak = power_state_list;
+ host.power_peak = xbt_dynar_new(sizeof(double), NULL);
+ xbt_dynar_push(host.power_peak,&cluster->power);
host.pstate = 0;
//host.power_peak = cluster->power;
host.initial_state = SURF_RESOURCE_ON;
host.coord = "";
sg_platf_new_host(&host);
+ xbt_dynar_free(&host.power_peak);
XBT_DEBUG("</host>");
XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%f\"\tlat=\"%f\"/>", link_id,
host.initial_state = SURF_RESOURCE_ON;
host.id = host_id;
- xbt_dynar_t power_state_list = xbt_dynar_new(sizeof(double), NULL);
- xbt_dynar_push(power_state_list,&peer->power);
- host.power_peak = power_state_list;
+ host.power_peak = xbt_dynar_new(sizeof(double), NULL);
+ xbt_dynar_push(host.power_peak,&peer->power);
host.pstate = 0;
//host.power_peak = peer->power;
host.power_scale = 1.0;
host.state_trace = peer->state_trace;
host.core_amount = 1;
sg_platf_new_host(&host);
+ xbt_dynar_free(&host.power_peak);
s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
memset(&link, 0, sizeof(link));
host.coord = A_surfxml_host_coordinates;
sg_platf_new_host(&host);
+ xbt_dynar_free(&host.power_peak);
current_property_set = NULL;
}