Commit 32ea6ea0 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

Put opening curly brace of functions on a separate line.

[r27145]
parent 6b124543
...@@ -76,7 +76,8 @@ void ir_verify_arr(const void *arr) ...@@ -76,7 +76,8 @@ void ir_verify_arr(const void *arr)
* *
* @remark Helper function, use NEW_ARR_D() instead. * @remark Helper function, use NEW_ARR_D() instead.
*/ */
void *ir_new_arr_d(struct obstack *obstack, int nelts, size_t elts_size) { void *ir_new_arr_d(struct obstack *obstack, int nelts, size_t elts_size)
{
ir_arr_descr *dp; ir_arr_descr *dp;
assert(obstack && (nelts >= 0)); assert(obstack && (nelts >= 0));
...@@ -99,7 +100,8 @@ void *ir_new_arr_d(struct obstack *obstack, int nelts, size_t elts_size) { ...@@ -99,7 +100,8 @@ void *ir_new_arr_d(struct obstack *obstack, int nelts, size_t elts_size) {
* *
* @remark Helper function, use NEW_ARR_F() instead. * @remark Helper function, use NEW_ARR_F() instead.
*/ */
void *ir_new_arr_f(int nelts, size_t elts_size) { void *ir_new_arr_f(int nelts, size_t elts_size)
{
ir_arr_descr *new; ir_arr_descr *new;
assert (nelts >= 0); assert (nelts >= 0);
...@@ -116,7 +118,8 @@ void *ir_new_arr_f(int nelts, size_t elts_size) { ...@@ -116,7 +118,8 @@ void *ir_new_arr_f(int nelts, size_t elts_size) {
* *
* @remark Helper function, use DEL_ARR_F() instead. * @remark Helper function, use DEL_ARR_F() instead.
*/ */
void ir_del_arr_f(void *elts) { void ir_del_arr_f(void *elts)
{
ir_arr_descr *dp = ARR_DESCR (elts); ir_arr_descr *dp = ARR_DESCR (elts);
ARR_VRFY (elts); ARR_VRFY (elts);
...@@ -143,7 +146,8 @@ void ir_del_arr_f(void *elts) { ...@@ -143,7 +146,8 @@ void ir_del_arr_f(void *elts) {
* *
* @remark Helper function, use ARR_SETLEN() instead. * @remark Helper function, use ARR_SETLEN() instead.
*/ */
void *ir_arr_setlen (void *elts, int nelts, size_t elts_size) { void *ir_arr_setlen (void *elts, int nelts, size_t elts_size)
{
ir_arr_descr *dp = ARR_DESCR (elts); ir_arr_descr *dp = ARR_DESCR (elts);
assert ((dp->magic == ARR_F_MAGIC) && (nelts >= 0)); assert ((dp->magic == ARR_F_MAGIC) && (nelts >= 0));
...@@ -169,7 +173,8 @@ void *ir_arr_setlen (void *elts, int nelts, size_t elts_size) { ...@@ -169,7 +173,8 @@ void *ir_arr_setlen (void *elts, int nelts, size_t elts_size) {
* *
* @remark Helper function, use ARR_RESIZE() instead. * @remark Helper function, use ARR_RESIZE() instead.
*/ */
void *ir_arr_resize(void *elts, int nelts, size_t eltsize) { void *ir_arr_resize(void *elts, int nelts, size_t eltsize)
{
ir_arr_descr *dp = ARR_DESCR(elts); ir_arr_descr *dp = ARR_DESCR(elts);
int n; int n;
...@@ -202,7 +207,8 @@ void *ir_arr_resize(void *elts, int nelts, size_t eltsize) { ...@@ -202,7 +207,8 @@ void *ir_arr_resize(void *elts, int nelts, size_t eltsize) {
* Do NOT use is in code, use ARR_LEN() macro! * Do NOT use is in code, use ARR_LEN() macro!
* This function is intended to be called from a debugger. * This function is intended to be called from a debugger.
*/ */
int array_len(const void *arr) { int array_len(const void *arr)
{
return ARR_LEN(arr); return ARR_LEN(arr);
} }
...@@ -211,7 +217,8 @@ int array_len(const void *arr) { ...@@ -211,7 +217,8 @@ int array_len(const void *arr) {
* Do NOT use is in code!. * Do NOT use is in code!.
* This function is intended to be called from a debugger. * This function is intended to be called from a debugger.
*/ */
ir_arr_descr *array_descr(const void *arr) { ir_arr_descr *array_descr(const void *arr)
{
if (! arr) if (! arr)
return NULL; return NULL;
return ARR_DESCR(arr); return ARR_DESCR(arr);
......
...@@ -164,7 +164,8 @@ void bipartite_dump_f(FILE *f, const bipartite_t *gr) ...@@ -164,7 +164,8 @@ void bipartite_dump_f(FILE *f, const bipartite_t *gr)
} }
} }
void bipartite_dump(const char *name, const bipartite_t *gr) { void bipartite_dump(const char *name, const bipartite_t *gr)
{
FILE *f = fopen(name, "w"); FILE *f = fopen(name, "w");
if (f) { if (f) {
......
...@@ -37,7 +37,8 @@ struct eset { ...@@ -37,7 +37,8 @@ struct eset {
#define INITIAL_SLOTS 64 #define INITIAL_SLOTS 64
static int pcmp(const void *p1, const void *p2, size_t size) { static int pcmp(const void *p1, const void *p2, size_t size)
{
const void **q1 = (const void **)p1; const void **q1 = (const void **)p1;
const void **q2 = (const void **)p2; const void **q2 = (const void **)p2;
(void) size; (void) size;
...@@ -46,12 +47,14 @@ static int pcmp(const void *p1, const void *p2, size_t size) { ...@@ -46,12 +47,14 @@ static int pcmp(const void *p1, const void *p2, size_t size) {
} }
eset * eset_create(void) { eset * eset_create(void)
{
return (eset *) new_set(pcmp, INITIAL_SLOTS); return (eset *) new_set(pcmp, INITIAL_SLOTS);
} }
eset * eset_copy(eset *source) { eset * eset_copy(eset *source)
{
eset * ret = eset_create(); eset * ret = eset_create();
void * p; void * p;
for (p = eset_first(source); p; p = eset_next(source)) { for (p = eset_first(source); p; p = eset_next(source)) {
...@@ -61,40 +64,47 @@ eset * eset_copy(eset *source) { ...@@ -61,40 +64,47 @@ eset * eset_copy(eset *source) {
} }
void eset_destroy(eset *s) { void eset_destroy(eset *s)
{
del_set((set *)s); del_set((set *)s);
} }
/* Returns the number of elements in the set. */ /* Returns the number of elements in the set. */
int eset_count(eset *s) { int eset_count(eset *s)
{
return set_count((set *)s); return set_count((set *)s);
} }
void eset_insert(eset *s, void *p) { void eset_insert(eset *s, void *p)
{
if (!eset_contains(s, p)) { if (!eset_contains(s, p)) {
set_insert((set *)s, &p, sizeof(p), HASH_PTR(p)); set_insert((set *)s, &p, sizeof(p), HASH_PTR(p));
} }
} }
int eset_contains(eset *s, void *p) { int eset_contains(eset *s, void *p)
{
return set_find((set *)s, &p, sizeof(p), HASH_PTR(p)) != NULL; return set_find((set *)s, &p, sizeof(p), HASH_PTR(p)) != NULL;
} }
void * eset_first(eset *s) { void * eset_first(eset *s)
{
void * p = set_first((set *) s); void * p = set_first((set *) s);
return p == NULL ? NULL : *((void **)p); return p == NULL ? NULL : *((void **)p);
} }
void * eset_next(eset *s) { void * eset_next(eset *s)
{
void *p = set_next((set *) s); void *p = set_next((set *) s);
return p == NULL ? NULL : *((void **)p); return p == NULL ? NULL : *((void **)p);
} }
void eset_insert_all(eset *target, eset *source) { void eset_insert_all(eset *target, eset *source)
{
void *p; void *p;
for (p = eset_first(source); p; p = eset_next(source)) { for (p = eset_first(source); p; p = eset_next(source)) {
eset_insert(target, p); eset_insert(target, p);
......
...@@ -41,13 +41,15 @@ struct _gs_matrix_t { ...@@ -41,13 +41,15 @@ struct _gs_matrix_t {
row_col_t *rows; row_col_t *rows;
}; };
static inline void alloc_cols(row_col_t *row, int c_cols) { static inline void alloc_cols(row_col_t *row, int c_cols)
{
assert(c_cols > row->c_cols); assert(c_cols > row->c_cols);
row->c_cols = c_cols; row->c_cols = c_cols;
row->cols = XREALLOC(row->cols, col_val_t, c_cols); row->cols = XREALLOC(row->cols, col_val_t, c_cols);
} }
static inline void alloc_rows(gs_matrix_t *m, int c_rows, int c_cols, int begin_init) { static inline void alloc_rows(gs_matrix_t *m, int c_rows, int c_cols, int begin_init)
{
int i; int i;
assert(c_rows > m->c_rows); assert(c_rows > m->c_rows);
...@@ -64,7 +66,8 @@ static inline void alloc_rows(gs_matrix_t *m, int c_rows, int c_cols, int begin_ ...@@ -64,7 +66,8 @@ static inline void alloc_rows(gs_matrix_t *m, int c_rows, int c_cols, int begin_
} }
} }
gs_matrix_t *gs_new_matrix(int n_init_rows, int n_init_cols) { gs_matrix_t *gs_new_matrix(int n_init_rows, int n_init_cols)
{
gs_matrix_t *res = XMALLOCZ(gs_matrix_t); gs_matrix_t *res = XMALLOCZ(gs_matrix_t);
if (n_init_rows < 16) if (n_init_rows < 16)
n_init_rows = 16; n_init_rows = 16;
...@@ -73,7 +76,8 @@ gs_matrix_t *gs_new_matrix(int n_init_rows, int n_init_cols) { ...@@ -73,7 +76,8 @@ gs_matrix_t *gs_new_matrix(int n_init_rows, int n_init_cols) {
return res; return res;
} }
void gs_delete_matrix(gs_matrix_t *m) { void gs_delete_matrix(gs_matrix_t *m)
{
int i; int i;
for (i = 0; i < m->c_rows; ++i) { for (i = 0; i < m->c_rows; ++i) {
if (m->rows[i].c_cols) if (m->rows[i].c_cols)
...@@ -84,7 +88,8 @@ void gs_delete_matrix(gs_matrix_t *m) { ...@@ -84,7 +88,8 @@ void gs_delete_matrix(gs_matrix_t *m) {
xfree(m); xfree(m);
} }
unsigned gs_matrix_get_n_entries(const gs_matrix_t *m) { unsigned gs_matrix_get_n_entries(const gs_matrix_t *m)
{
int i; int i;
unsigned n_entries = 0; unsigned n_entries = 0;
...@@ -96,7 +101,8 @@ unsigned gs_matrix_get_n_entries(const gs_matrix_t *m) { ...@@ -96,7 +101,8 @@ unsigned gs_matrix_get_n_entries(const gs_matrix_t *m) {
return n_entries - m->n_zero_entries; return n_entries - m->n_zero_entries;
} }
int gs_matrix_get_sizeof_allocated_memory(const gs_matrix_t *m) { int gs_matrix_get_sizeof_allocated_memory(const gs_matrix_t *m)
{
int i, n_col_val_ts = 0; int i, n_col_val_ts = 0;
for (i = 0; i < m->c_rows; ++i) for (i = 0; i < m->c_rows; ++i)
n_col_val_ts += m->rows[i].c_cols; n_col_val_ts += m->rows[i].c_cols;
...@@ -104,13 +110,15 @@ int gs_matrix_get_sizeof_allocated_memory(const gs_matrix_t *m) { ...@@ -104,13 +110,15 @@ int gs_matrix_get_sizeof_allocated_memory(const gs_matrix_t *m) {
return n_col_val_ts * sizeof(col_val_t) + m->c_rows * sizeof(row_col_t) + sizeof(gs_matrix_t); return n_col_val_ts * sizeof(col_val_t) + m->c_rows * sizeof(row_col_t) + sizeof(gs_matrix_t);
} }
void gs_matrix_assure_row_capacity(gs_matrix_t *m, int row, int min_capacity) { void gs_matrix_assure_row_capacity(gs_matrix_t *m, int row, int min_capacity)
{
row_col_t *the_row = &m->rows[row]; row_col_t *the_row = &m->rows[row];
if (the_row->c_cols < min_capacity) if (the_row->c_cols < min_capacity)
alloc_cols(the_row, min_capacity); alloc_cols(the_row, min_capacity);
} }
void gs_matrix_trim_row_capacities(gs_matrix_t *m) { void gs_matrix_trim_row_capacities(gs_matrix_t *m)
{
int i; int i;
for (i = 0; i < m->c_rows; ++i) { for (i = 0; i < m->c_rows; ++i) {
row_col_t *the_row = &m->rows[i]; row_col_t *the_row = &m->rows[i];
...@@ -124,7 +132,8 @@ void gs_matrix_trim_row_capacities(gs_matrix_t *m) { ...@@ -124,7 +132,8 @@ void gs_matrix_trim_row_capacities(gs_matrix_t *m) {
} }
} }
void gs_matrix_delete_zero_entries(gs_matrix_t *m) { void gs_matrix_delete_zero_entries(gs_matrix_t *m)
{
int i, read_pos; int i, read_pos;
for (i = 0; i < m->c_rows; ++i) { for (i = 0; i < m->c_rows; ++i) {
row_col_t *the_row = &m->rows[i]; row_col_t *the_row = &m->rows[i];
...@@ -139,7 +148,8 @@ void gs_matrix_delete_zero_entries(gs_matrix_t *m) { ...@@ -139,7 +148,8 @@ void gs_matrix_delete_zero_entries(gs_matrix_t *m) {
m->n_zero_entries = 0; m->n_zero_entries = 0;
} }
void gs_matrix_set(gs_matrix_t *m, int row, int col, double val) { void gs_matrix_set(gs_matrix_t *m, int row, int col, double val)
{
row_col_t *the_row; row_col_t *the_row;
col_val_t *cols; col_val_t *cols;
int min, max, c, i; int min, max, c, i;
...@@ -202,7 +212,8 @@ void gs_matrix_set(gs_matrix_t *m, int row, int col, double val) { ...@@ -202,7 +212,8 @@ void gs_matrix_set(gs_matrix_t *m, int row, int col, double val) {
assert(c>=the_row->n_cols-1 || the_row->cols[c].col_idx < the_row->cols[c+1].col_idx); assert(c>=the_row->n_cols-1 || the_row->cols[c].col_idx < the_row->cols[c+1].col_idx);
} }
double gs_matrix_get(const gs_matrix_t *m, int row, int col) { double gs_matrix_get(const gs_matrix_t *m, int row, int col)
{
row_col_t *the_row; row_col_t *the_row;
int c; int c;
...@@ -231,7 +242,8 @@ double gs_matrix_get(const gs_matrix_t *m, int row, int col) { ...@@ -231,7 +242,8 @@ double gs_matrix_get(const gs_matrix_t *m, int row, int col) {
* *
* Note that the diagonal element is stored separately in this matrix implementation. * Note that the diagonal element is stored separately in this matrix implementation.
* */ * */
double gs_matrix_gauss_seidel(const gs_matrix_t *m, double *x, int n) { double gs_matrix_gauss_seidel(const gs_matrix_t *m, double *x, int n)
{
double res = 0.0; double res = 0.0;
int r; int r;
...@@ -278,7 +290,8 @@ void gs_matrix_export(const gs_matrix_t *m, double *nw, int size) ...@@ -278,7 +290,8 @@ void gs_matrix_export(const gs_matrix_t *m, double *nw, int size)
} }
} }
void gs_matrix_dump(const gs_matrix_t *m, int a, int b, FILE *out) { void gs_matrix_dump(const gs_matrix_t *m, int a, int b, FILE *out)
{
int effective_rows = MIN(a, m->c_rows); int effective_rows = MIN(a, m->c_rows);
int r, c, i; int r, c, i;
double *elems = XMALLOCN(double, b); double *elems = XMALLOCN(double, b);
...@@ -313,7 +326,8 @@ void gs_matrix_dump(const gs_matrix_t *m, int a, int b, FILE *out) { ...@@ -313,7 +326,8 @@ void gs_matrix_dump(const gs_matrix_t *m, int a, int b, FILE *out) {
xfree(elems); xfree(elems);
} }
void gs_matrix_self_test(int d) { void gs_matrix_self_test(int d)
{
int i, o; int i, o;
gs_matrix_t *m = gs_new_matrix(10, 10); gs_matrix_t *m = gs_new_matrix(10, 10);
......
...@@ -57,7 +57,8 @@ struct _hungarian_problem_t { ...@@ -57,7 +57,8 @@ struct _hungarian_problem_t {
DEBUG_ONLY(firm_dbg_module_t *dbg); DEBUG_ONLY(firm_dbg_module_t *dbg);
}; };
static void hungarian_dump_f(FILE *f, int **C, int rows, int cols, int width) { static void hungarian_dump_f(FILE *f, int **C, int rows, int cols, int width)
{
int i, j; int i, j;
fprintf(f , "\n"); fprintf(f , "\n");
...@@ -71,14 +72,16 @@ static void hungarian_dump_f(FILE *f, int **C, int rows, int cols, int width) { ...@@ -71,14 +72,16 @@ static void hungarian_dump_f(FILE *f, int **C, int rows, int cols, int width) {
fprintf(f, "\n"); fprintf(f, "\n");
} }
void hungarian_print_cost_matrix(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); hungarian_dump_f(stderr, p->cost, p->num_rows, p->num_cols, width);
} }
/** /**
* Create the object and allocate memory for the data structures. * Create the object and allocate memory for the data structures.
*/ */
hungarian_problem_t *hungarian_new(int rows, int cols, int match_type) { hungarian_problem_t *hungarian_new(int rows, int cols, int match_type)
{
int i; int i;
hungarian_problem_t *p = XMALLOCZ(hungarian_problem_t); hungarian_problem_t *p = XMALLOCZ(hungarian_problem_t);
...@@ -120,7 +123,8 @@ hungarian_problem_t *hungarian_new(int rows, int cols, int match_type) { ...@@ -120,7 +123,8 @@ hungarian_problem_t *hungarian_new(int rows, int cols, int match_type) {
/** /**
* Prepare the cost matrix. * Prepare the cost matrix.
*/ */
void hungarian_prepare_cost_matrix(hungarian_problem_t *p, int mode) { void hungarian_prepare_cost_matrix(hungarian_problem_t *p, int mode)
{
int i, j; int i, j;
if (mode == HUNGARIAN_MODE_MAXIMIZE_UTIL) { if (mode == HUNGARIAN_MODE_MAXIMIZE_UTIL) {
...@@ -140,7 +144,8 @@ void hungarian_prepare_cost_matrix(hungarian_problem_t *p, int mode) { ...@@ -140,7 +144,8 @@ void hungarian_prepare_cost_matrix(hungarian_problem_t *p, int mode) {
/** /**
* Set cost[left][right] to cost. * Set cost[left][right] to cost.
*/ */
void hungarian_add(hungarian_problem_t *p, int left, int right, int cost) { void hungarian_add(hungarian_problem_t *p, int left, int right, int cost)
{
assert(p->num_rows > left && "Invalid row selected."); assert(p->num_rows > left && "Invalid row selected.");
assert(p->num_cols > right && "Invalid column selected."); assert(p->num_cols > right && "Invalid column selected.");
assert(cost >= 0); assert(cost >= 0);
...@@ -157,7 +162,8 @@ void hungarian_add(hungarian_problem_t *p, int left, int right, int cost) { ...@@ -157,7 +162,8 @@ void hungarian_add(hungarian_problem_t *p, int left, int right, int cost) {
/** /**
* Set cost[left][right] to 0. * Set cost[left][right] to 0.
*/ */
void hungarian_remv(hungarian_problem_t *p, int left, int right) { void hungarian_remv(hungarian_problem_t *p, int left, int right)
{
assert(p->num_rows > left && "Invalid row selected."); assert(p->num_rows > left && "Invalid row selected.");
assert(p->num_cols > right && "Invalid column selected."); assert(p->num_cols > right && "Invalid column selected.");
...@@ -172,7 +178,8 @@ void hungarian_remv(hungarian_problem_t *p, int left, int right) { ...@@ -172,7 +178,8 @@ void hungarian_remv(hungarian_problem_t *p, int left, int right) {
/** /**
* Frees all allocated memory. * Frees all allocated memory.
*/ */
void hungarian_free(hungarian_problem_t* p) { void hungarian_free(hungarian_problem_t* p)
{
obstack_free(&p->obst, NULL); obstack_free(&p->obst, NULL);
xfree(p); xfree(p);
} }
...@@ -180,7 +187,8 @@ void hungarian_free(hungarian_problem_t* p) { ...@@ -180,7 +187,8 @@ void hungarian_free(hungarian_problem_t* p) {
/** /**
* Do the assignment. * Do the assignment.
*/ */
int hungarian_solve(hungarian_problem_t* p, int *assignment, int *final_cost, int cost_threshold) { int hungarian_solve(hungarian_problem_t* p, int *assignment, int *final_cost, int cost_threshold)
{
int i, j, m, n, k, l, s, t, q, unmatched, cost; int i, j, m, n, k, l, s, t, q, unmatched, cost;
int *col_mate; int *col_mate;
int *row_mate; int *row_mate;
......
...@@ -39,7 +39,8 @@ ...@@ -39,7 +39,8 @@
* @param list the list for which to allocate the element. * @param list the list for which to allocate the element.
* @return the newly allocated, uninitialized element. * @return the newly allocated, uninitialized element.
*/ */
static plist_element_t *allocate_element(plist_t* list) { static plist_element_t *allocate_element(plist_t* list)
{
plist_element_t *new_element; plist_element_t *new_element;
if (list->first_free_element != NULL) { if (list->first_free_element != NULL) {
...@@ -54,7 +55,8 @@ static plist_element_t *allocate_element(plist_t* list) { ...@@ -54,7 +55,8 @@ static plist_element_t *allocate_element(plist_t* list) {
return new_element; return new_element;
} }
plist_t *plist_new(void) { plist_t *plist_new(void)
{
plist_t *list = xmalloc(sizeof(*list) + sizeof(*list->obst)); plist_t *list = xmalloc(sizeof(*list) + sizeof(*list->obst));
list->obst = (struct obstack *)&list[1]; list->obst = (struct obstack *)&list[1];
...@@ -68,7 +70,8 @@ plist_t *plist_new(void) { ...@@ -68,7 +70,8 @@ plist_t *plist_new(void) {
return list; return list;
} }
plist_t *plist_obstack_new(struct obstack *obst) { plist_t *plist_obstack_new(struct obstack *obst)
{
plist_t *list = OALLOC(obst, plist_t); plist_t *list = OALLOC(obst, plist_t);
list->obst = obst; list->obst = obst;
...@@ -81,7 +84,8 @@ plist_t *plist_obstack_new(struct obstack *obst) { ...@@ -81,7 +84,8 @@ plist_t *plist_obstack_new(struct obstack *obst) {
return list; return list;
} }
void plist_free(plist_t *list) { void plist_free(plist_t *list)
{
list->first_element = NULL; list->first_element = NULL;
list->last_element = NULL; list->last_element = NULL;
list->first_free_element = NULL; list->first_free_element = NULL;
...@@ -93,7 +97,8 @@ void plist_free(plist_t *list) { ...@@ -93,7 +97,8 @@ void plist_free(plist_t *list) {
} }
} }
void plist_insert_back(plist_t *list, void *value) { void plist_insert_back(plist_t *list, void *value)
{
if (list->last_element != NULL) { if (list->last_element != NULL) {
plist_insert_after(list, list->last_element, value); plist_insert_after(list, list->last_element, value);
} }
...@@ -108,7 +113,8 @@ void plist_insert_back(plist_t *list, void *value) { ...@@ -108,7 +113,8 @@ void plist_insert_back(plist_t *list, void *value) {
} }
} }
void plist_insert_front(plist_t *list, void *value) { void plist_insert_front(plist_t *list, void *value)
{
if (list->first_element != NULL) { if (list->first_element != NULL) {
plist_insert_before(list, list->first_element, value);