Commit e23882e6 authored by Matthias Braun's avatar Matthias Braun
Browse files

Fixed bad memset, which didn't correctly initialize the hungarian structure

Added an assert to assure costs are >= 0, not sure if that is correct, if it is
not then max_costs should be initialized to INT_MIN...

[r8568]
parent db2d5cd6
......@@ -88,7 +88,7 @@ hungarian_problem_t *hungarian_new(int rows, int cols, int width, int match_type
int i;
hungarian_problem_t *p = xmalloc(sizeof(*p));
memset(p, 0, sizeof(p));
memset(p, 0, sizeof(p[0]));
FIRM_DBG_REGISTER(p->dbg, "firm.hungarian");
......@@ -152,6 +152,7 @@ void hungarian_prepare_cost_matrix(hungarian_problem_t *p, int mode) {
void hungarian_add(hungarian_problem_t *p, int left, int right, int cost) {
assert(p->num_rows > left && "Invalid row selected.");
assert(p->num_cols > right && "Invalid column selected.");
assert(cost >= 0);
p->cost[left][right] = cost;
p->max_cost = MAX(p->max_cost, cost);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment