diff options
author | olivier gayot <ogayot@free.fr> | 2012-12-13 11:59:30 +0000 |
---|---|---|
committer | olivier gayot <ogayot@free.fr> | 2012-12-13 11:59:30 +0000 |
commit | aba329310979832911cf0f93243e7c6d27a1fc5d (patch) | |
tree | 5f48f828db5bbe84adf5436efa05b6e0378dec1f | |
parent | eeb456d954b90c8f1c9247d91afde52d690778ff (diff) |
We do not change the vectors at each reccursion, we create a new one
instead, so we can set the source vectors to const.
-rw-r--r-- | solver.c | 12 | ||||
-rw-r--r-- | solver.h | 2 |
2 files changed, 8 insertions, 6 deletions
@@ -30,10 +30,10 @@ typedef struct { } solution_t; static solution_t solution_g; -static vect_t *vect_g; +static const vect_t *vect_g; static int result; -static int closer = -1; +static int closer; /* {{{ display */ @@ -78,7 +78,7 @@ static void display_solution(void) /* }}} */ static inline -void construct_new_vect(vect_t *new_vect, vect_t *vect, unsigned v1, unsigned v2) +void construct_new_vect(vect_t *new_vect, const vect_t *vect, unsigned v1, unsigned v2) { unsigned j = 0; @@ -91,7 +91,7 @@ void construct_new_vect(vect_t *new_vect, vect_t *vect, unsigned v1, unsigned v2 } } -static void solve_rec(vect_t *vect) +static void solve_rec(const vect_t *vect) { vect_t new_vect; @@ -160,10 +160,12 @@ static void solve_rec(vect_t *vect) } /* public function to use */ -void solve(vect_t *vect, int _result) +void solve(const vect_t *vect, int _result) { + closer = -1; vect_g = vect; result = _result; + solution_g.computation = malloc(sizeof(computation_t) * vect->len); solution_g.level = 0; @@ -6,6 +6,6 @@ typedef struct { unsigned len; } vect_t; -void solve(vect_t *vect, int result); +void solve(const vect_t *vect, int result); #endif /* SOLVER_H */ |