/* Printing Objective */
var_list = &(sys->variable_set);
- sprintf(print_buf, "MAX-MIN ( ");
+ snprintf(print_buf,11, "MAX-MIN ( ");
trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
- strcat(trace_buf, print_buf);
+ strncat(trace_buf, print_buf, strlen(print_buf));
xbt_swag_foreach(_var, var_list) {
var = (lmm_variable_t)_var;
- sprintf(print_buf, "'%d'(%f) ", var->id_int, var->weight);
+ snprintf(print_buf,1024, "'%d'(%f) ", var->id_int, var->weight);
trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
- strcat(trace_buf, print_buf);
+ strncat(trace_buf, print_buf, strlen(print_buf));
}
- sprintf(print_buf, ")");
+ snprintf(print_buf,2, ")");
trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
- strcat(trace_buf, print_buf);
+ strncat(trace_buf, print_buf, strlen(print_buf));
XBT_DEBUG("%20s", trace_buf);
trace_buf[0] = '\000';
sum = 0.0;
//Show the enabled variables
elem_list = &(cnst->enabled_element_set);
- sprintf(print_buf, "\t");
+ snprintf(print_buf,2, "\t");
trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
- strcat(trace_buf, print_buf);
- sprintf(print_buf, "%s(",(cnst->sharing_policy)?"":"max");
+ strncat(trace_buf, print_buf, strlen(print_buf));
+ snprintf(print_buf,1024, "%s(",(cnst->sharing_policy)?"":"max");
trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
- strcat(trace_buf, print_buf);
+ strncat(trace_buf, print_buf, strlen(print_buf));
xbt_swag_foreach(_elem, elem_list) {
elem = (lmm_element_t)_elem;
- sprintf(print_buf, "%f.'%d'(%f) %s ", elem->value,
+ snprintf(print_buf,1024, "%f.'%d'(%f) %s ", elem->value,
elem->variable->id_int, elem->variable->value,(cnst->sharing_policy)?"+":",");
trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
- strcat(trace_buf, print_buf);
+ strncat(trace_buf, print_buf, strlen(print_buf));
if(cnst->sharing_policy)
sum += elem->value * elem->variable->value;
else
elem_list = &(cnst->disabled_element_set);
xbt_swag_foreach(_elem, elem_list) {
elem = (lmm_element_t)_elem;
- sprintf(print_buf, "%f.'%d'(%f) %s ", elem->value,
+ snprintf(print_buf,1024, "%f.'%d'(%f) %s ", elem->value,
elem->variable->id_int, elem->variable->value,(cnst->sharing_policy)?"+":",");
trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
- strcat(trace_buf, print_buf);
+ strncat(trace_buf, print_buf, strlen(print_buf));
if(cnst->sharing_policy)
sum += elem->value * elem->variable->value;
else
sum = MAX(sum,elem->value * elem->variable->value);
}
- sprintf(print_buf, "0) <= %f ('%d')", cnst->bound, cnst->id_int);
+ snprintf(print_buf,1024, "0) <= %f ('%d')", cnst->bound, cnst->id_int);
trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
- strcat(trace_buf, print_buf);
+ strncat(trace_buf, print_buf, strlen(print_buf));
if (!cnst->sharing_policy) {
- sprintf(print_buf, " [MAX-Constraint]");
+ snprintf(print_buf,1024, " [MAX-Constraint]");
trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
- strcat(trace_buf, print_buf);
+ strncat(trace_buf, print_buf, strlen(print_buf));
}
XBT_DEBUG("%s", trace_buf);
trace_buf[0] = '\000';
*
* Makes var->bound equal to bound. Whenever this function is called a change is signed in the system. To
* avoid false system changing detection it is a good idea to test (bound != 0) before calling it.
-*/
+ */
void lmm_update_variable_bound(lmm_system_t sys, lmm_variable_t var, double bound)
{
sys->modified = 1;
return cnstr->concurrency_limit - cnstr->concurrency_current;
}
-/** \brief Measure the minimum concurrency slack across all constraints where var is involved
- *
- * \param The variable to check for
- */
+/** \brief Measure the minimum concurrency slack across all constraints where the given var is involved */
int lmm_cnstrs_min_concurrency_slack(lmm_variable_t var){
int i;
//FIXME MARTIN: Replace by infinite value std::numeric_limits<int>::(max)(), or something better within Simgrid?