X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fadt%2Fhungarian.c;h=32f1d6879e3ccbaffa89952bf10e2cad8d0aff12;hb=fbac84f353f42aec374c6e441782ceb60740e60f;hp=943567edc14cdc274f34422b29b336e9b398018f;hpb=e23882e6aace898f9d99a84b56ddfd6ea96d41bc;p=libfirm diff --git a/ir/adt/hungarian.c b/ir/adt/hungarian.c index 943567edc..32f1d6879 100644 --- a/ir/adt/hungarian.c +++ b/ir/adt/hungarian.c @@ -24,11 +24,12 @@ ******************************************************************** ********************************************************************/ -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif +/** + * @file + * @brief Solving the Minimum Assignment Problem using the Hungarian Method. + * @version $Id$ + */ +#include "config.h" #include #include @@ -57,7 +58,7 @@ struct _hungarian_problem_t { DEBUG_ONLY(firm_dbg_module_t *dbg); }; -static INLINE void *get_init_mem(struct obstack *obst, long sz) { +static inline void *get_init_mem(struct obstack *obst, long sz) { void *p = obstack_alloc(obst, sz); memset(p, 0, sz); return p; @@ -86,9 +87,7 @@ void hungarian_print_costmatrix(hungarian_problem_t *p) { */ 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[0])); + hungarian_problem_t *p = XMALLOCZ(hungarian_problem_t); FIRM_DBG_REGISTER(p->dbg, "firm.hungarian"); @@ -204,15 +203,15 @@ int hungarian_solve(hungarian_problem_t* p, int *assignment, int *final_cost, in m = p->num_rows; n = p->num_cols; - col_mate = xcalloc(p->num_rows, sizeof(col_mate[0])); - unchosen_row = xcalloc(p->num_rows, sizeof(unchosen_row[0])); - row_dec = xcalloc(p->num_rows, sizeof(row_dec[0])); - slack_row = xcalloc(p->num_rows, sizeof(slack_row[0])); + col_mate = XMALLOCNZ(int, p->num_rows); + unchosen_row = XMALLOCNZ(int, p->num_rows); + row_dec = XMALLOCNZ(int, p->num_rows); + slack_row = XMALLOCNZ(int, p->num_rows); - row_mate = xcalloc(p->num_cols, sizeof(row_mate[0])); - parent_row = xcalloc(p->num_cols, sizeof(parent_row[0])); - col_inc = xcalloc(p->num_cols, sizeof(col_inc[0])); - slack = xcalloc(p->num_cols, sizeof(slack[0])); + row_mate = XMALLOCNZ(int, p->num_cols); + parent_row = XMALLOCNZ(int, p->num_cols); + col_inc = XMALLOCNZ(int, p->num_cols); + slack = XMALLOCNZ(int, p->num_cols); memset(assignment, -1, m * sizeof(assignment[0]));