mem leak patched
This commit is contained in:
1 parent
edb972d99f
commit
8dbb7e620c
1 file changed
+6
-6
+6
-6
@@ -18,6 +18,7 @@ bool test_game_is_over(void){
|
|||||||
game g = game_default_solution();
|
game g = game_default_solution();
|
||||||
game_update_flags(g);
|
game_update_flags(g);
|
||||||
assert(game_is_over(g));
|
assert(game_is_over(g));
|
||||||
|
game_delete(g);
|
||||||
g = game_default();
|
g = game_default();
|
||||||
game_update_flags(g);
|
game_update_flags(g);
|
||||||
assert(!game_is_over(g));
|
assert(!game_is_over(g));
|
||||||
@@ -138,6 +139,7 @@ bool test_game_default_solution(void){
|
|||||||
game_update_flags(g1);
|
game_update_flags(g1);
|
||||||
assert(game_equal(g,g1));
|
assert(game_equal(g,g1));
|
||||||
game_delete(g);
|
game_delete(g);
|
||||||
|
game_delete(g1);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,9 +358,7 @@ bool check_update(game g){
|
|||||||
// a > 2 = temps d'exec > 3 min et expo
|
// a > 2 = temps d'exec > 3 min et expo
|
||||||
bool brutforce(game g,int a, bool * deldup){
|
bool brutforce(game g,int a, bool * deldup){
|
||||||
// char c;
|
// char c;
|
||||||
bool * delDupNext;
|
bool * delDupNext = (bool *) calloc(DEFAULT_SIZE*DEFAULT_SIZE,sizeof(bool));
|
||||||
if (a > 0)
|
|
||||||
delDupNext = (bool *) calloc(DEFAULT_SIZE*DEFAULT_SIZE,sizeof(bool));
|
|
||||||
square list[] = {S_LIGHTBULB,S_MARK,S_BLACK0,S_BLACK1,S_BLACK2,S_BLACK3,S_BLACK4,S_BLACKU,S_BLANK};
|
square list[] = {S_LIGHTBULB,S_MARK,S_BLACK0,S_BLACK1,S_BLACK2,S_BLACK3,S_BLACK4,S_BLACKU,S_BLANK};
|
||||||
for (uint i = 0; i < DEFAULT_SIZE; i++){
|
for (uint i = 0; i < DEFAULT_SIZE; i++){
|
||||||
for (uint j = 0 ;j < DEFAULT_SIZE; j++){
|
for (uint j = 0 ;j < DEFAULT_SIZE; j++){
|
||||||
@@ -376,7 +376,6 @@ bool brutforce(game g,int a, bool * deldup){
|
|||||||
if (a > 0){
|
if (a > 0){
|
||||||
if (!brutforce(g,a-1,delDupNext)){
|
if (!brutforce(g,a-1,delDupNext)){
|
||||||
//printf("341\n");
|
//printf("341\n");
|
||||||
if (delDupNext != NULL)
|
|
||||||
free(delDupNext);
|
free(delDupNext);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -385,7 +384,6 @@ bool brutforce(game g,int a, bool * deldup){
|
|||||||
if (!check_update(g)){
|
if (!check_update(g)){
|
||||||
game_print(g);
|
game_print(g);
|
||||||
//printf("i:%d j:%d state : %d, flags: %d\n",i,j,game_get_state(g,i,j),game_get_flags(g,i,j));
|
//printf("i:%d j:%d state : %d, flags: %d\n",i,j,game_get_state(g,i,j),game_get_flags(g,i,j));
|
||||||
if (delDupNext != NULL && a > 0)
|
|
||||||
free(delDupNext);
|
free(delDupNext);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -394,7 +392,6 @@ bool brutforce(game g,int a, bool * deldup){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (delDupNext != NULL && a > 0)
|
|
||||||
free(delDupNext);
|
free(delDupNext);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -432,6 +429,8 @@ bool test_game_play_move(void){
|
|||||||
assert(!game_equal(g,g1));
|
assert(!game_equal(g,g1));
|
||||||
game_update_flags(g1);
|
game_update_flags(g1);
|
||||||
assert(game_equal(g,g1));
|
assert(game_equal(g,g1));
|
||||||
|
game_delete(g);
|
||||||
|
game_delete(g1);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -459,6 +458,7 @@ bool test_game_check_move(void){
|
|||||||
assert(game_check_move(g,1,0,S_BLANK));
|
assert(game_check_move(g,1,0,S_BLANK));
|
||||||
assert(game_check_move(g,1,0,S_MARK));
|
assert(game_check_move(g,1,0,S_MARK));
|
||||||
assert(game_check_move(g,1,0,S_LIGHTBULB));
|
assert(game_check_move(g,1,0,S_LIGHTBULB));
|
||||||
|
game_delete(g);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user