From: Matthias Braun Date: Mon, 29 Jan 2007 21:47:42 +0000 (+0000) Subject: Fixed bad memset, which didn't correctly initialize the hungarian structure X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;ds=sidebyside;h=e23882e6aace898f9d99a84b56ddfd6ea96d41bc;p=libfirm 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] --- diff --git a/ir/adt/hungarian.c b/ir/adt/hungarian.c index 7d08c437e..943567edc 100644 --- a/ir/adt/hungarian.c +++ b/ir/adt/hungarian.c @@ -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);