X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fadt%2Fhungarian.c;h=05910a9010090fc96b4a3d2c573adb760616689f;hb=d44b3844af84684de9b0213b77c175f80f8b84ee;hp=7d08c437ea65ce3f393c6f8dcd24cd9987d44a89;hpb=ed9c74ceca0655fb484f0537dbea43afa2ca0a7e;p=libfirm diff --git a/ir/adt/hungarian.c b/ir/adt/hungarian.c index 7d08c437e..05910a901 100644 --- a/ir/adt/hungarian.c +++ b/ir/adt/hungarian.c @@ -24,8 +24,11 @@ ******************************************************************** ********************************************************************/ -/* $Id$ */ - +/** + * @file + * @brief Solving the Minimum Assignment Problem using the Hungarian Method. + * @version $Id$ + */ #ifdef HAVE_CONFIG_H # include "config.h" #endif @@ -88,7 +91,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 +155,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);