DEBUG_ONLY(firm_dbg_module_t *dbg);
};
-static inline void *get_init_mem(struct obstack *obst, size_t sz) {
- void *p = obstack_alloc(obst, sz);
- memset(p, 0, sz);
- return p;
-}
-
static void hungarian_dump_f(FILE *f, int **C, int rows, int cols, int width) {
int i, j;
fprintf(f, "\n");
}
-void hungarian_print_costmatrix(hungarian_problem_t *p, int width) {
+void hungarian_print_cost_matrix(hungarian_problem_t *p, int width) {
hungarian_dump_f(stderr, p->cost, p->num_rows, p->num_cols, width);
}
}
/* allocate space for cost matrix */
- p->cost = (int **)get_init_mem(&p->obst, rows * sizeof(p->cost[0]));
+ p->cost = OALLOCNZ(&p->obst, int*, rows);
for (i = 0; i < p->num_rows; i++)
- p->cost[i] = (int *)get_init_mem(&p->obst, cols * sizeof(p->cost[0][0]));
+ p->cost[i] = OALLOCNZ(&p->obst, int, cols);
return p;
}
xfree(unchosen_row);
xfree(col_mate);
- *final_cost = cost;
+ if (final_cost != NULL)
+ *final_cost = cost;
return 0;
}