Make Valgind Happy (on my compuper)
This commit is contained in:
parent
82cc816f76
commit
94c88d09e9
1 changed files with 7 additions and 4 deletions
|
@ -44,7 +44,6 @@ s_tictactoe *create_empty_tictactoe() {
|
||||||
s_utictactoe *create_empty_utictactoe (uint inception_level) {
|
s_utictactoe *create_empty_utictactoe (uint inception_level) {
|
||||||
s_utictactoe * value = (s_utictactoe*) malloc(sizeof(s_utictactoe));
|
s_utictactoe * value = (s_utictactoe*) malloc(sizeof(s_utictactoe));
|
||||||
if ( value ) {
|
if ( value ) {
|
||||||
|
|
||||||
// then initiate outer_tictactoe amd inception_level
|
// then initiate outer_tictactoe amd inception_level
|
||||||
value->outer_tictactoe = create_empty_tictactoe();
|
value->outer_tictactoe = create_empty_tictactoe();
|
||||||
value->inception_level = inception_level;
|
value->inception_level = inception_level;
|
||||||
|
@ -59,13 +58,14 @@ s_utictactoe *create_empty_utictactoe (uint inception_level) {
|
||||||
// should be 9 simple ttt
|
// should be 9 simple ttt
|
||||||
|
|
||||||
value->inner_tictactoes = (s_tictactoe**)
|
value->inner_tictactoes = (s_tictactoe**)
|
||||||
malloc(sizeof(s_tictactoe));
|
malloc(TICTACTOE_SIZE*sizeof(s_tictactoe));
|
||||||
|
|
||||||
if ( ! value->inner_tictactoes ) {
|
if ( ! value->inner_tictactoes ) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( int i=0; i<TICTACTOE_SIZE; i++) {
|
for ( int i=0; i<TICTACTOE_SIZE; i++) {
|
||||||
|
//value->inner_tictactoes[i]= (s_tictactoe*) malloc(sizeof(s_tictactoe));
|
||||||
value->inner_tictactoes[i] = create_empty_tictactoe();
|
value->inner_tictactoes[i] = create_empty_tictactoe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,14 +75,16 @@ s_utictactoe *create_empty_utictactoe (uint inception_level) {
|
||||||
|
|
||||||
|
|
||||||
void free_move(s_move *p_move){
|
void free_move(s_move *p_move){
|
||||||
if ( p_move == NULL ) {
|
if ( p_move ) {
|
||||||
free(p_move);
|
free(p_move);
|
||||||
|
p_move = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_tictactoe(s_tictactoe *p_ttt){
|
void free_tictactoe(s_tictactoe *p_ttt){
|
||||||
if ( p_ttt) {
|
if ( p_ttt) {
|
||||||
free(p_ttt->content);
|
free(p_ttt->content);
|
||||||
|
p_ttt->content = NULL;
|
||||||
free(p_ttt);
|
free(p_ttt);
|
||||||
p_ttt = NULL;
|
p_ttt = NULL;
|
||||||
}
|
}
|
||||||
|
@ -96,6 +98,7 @@ void free_utictactoe(s_utictactoe *p_uttt){
|
||||||
free_tictactoe(p_uttt->inner_tictactoes[i]);
|
free_tictactoe(p_uttt->inner_tictactoes[i]);
|
||||||
}
|
}
|
||||||
free(p_uttt->inner_tictactoes);
|
free(p_uttt->inner_tictactoes);
|
||||||
|
p_uttt->inner_tictactoes = NULL;
|
||||||
}
|
}
|
||||||
free_tictactoe(p_uttt->outer_tictactoe);
|
free_tictactoe(p_uttt->outer_tictactoe);
|
||||||
free(p_uttt);
|
free(p_uttt);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue