summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorolivier gayot <ogayot@free.fr>2012-12-13 11:59:30 +0000
committerolivier gayot <ogayot@free.fr>2012-12-13 11:59:30 +0000
commitaba329310979832911cf0f93243e7c6d27a1fc5d (patch)
tree5f48f828db5bbe84adf5436efa05b6e0378dec1f
parenteeb456d954b90c8f1c9247d91afde52d690778ff (diff)
le_compte_est_bon: use const attribute with vectorsHEADmaster
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.c12
-rw-r--r--solver.h2
2 files changed, 8 insertions, 6 deletions
diff --git a/solver.c b/solver.c
index 27de4ca..d9eba10 100644
--- a/solver.c
+++ b/solver.c
@@ -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;
diff --git a/solver.h b/solver.h
index 357cd91..7fe71b2 100644
--- a/solver.h
+++ b/solver.h
@@ -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 */