projects
/
libfirm
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
db2d5cd
)
Fixed bad memset, which didn't correctly initialize the hungarian structure
author
Matthias Braun
<matze@braunis.de>
Mon, 29 Jan 2007 21:47:42 +0000
(21:47 +0000)
committer
Matthias Braun
<matze@braunis.de>
Mon, 29 Jan 2007 21:47:42 +0000
(21:47 +0000)
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]
ir/adt/hungarian.c
patch
|
blob
|
history
diff --git
a/ir/adt/hungarian.c
b/ir/adt/hungarian.c
index
7d08c43
..
943567e
100644
(file)
--- 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);