MatrixFree + release memory for debug purposes
This commit is contained in:
parent
1ad3a4c813
commit
05ed0ad350
|
@ -31,4 +31,9 @@ void PrintMatrixRow(matrix_t *matrix, size_t row);
|
|||
// row_len The number of entries in one row.
|
||||
matrix_t ParseMatrix(size_t row_len);
|
||||
|
||||
// Releases the memory associated to the given matrix.
|
||||
//
|
||||
// Usage after free results in undefined behaviour.
|
||||
void MatrixFree(matrix_t *matrix);
|
||||
|
||||
#endif // ACED_INCLUDES_MATRIX_H_
|
19
src/main.c
19
src/main.c
|
@ -158,13 +158,32 @@ int main(int argc, char *argv[]) {
|
|||
} // For loop over rhs_i
|
||||
} // For loop over lhs_i
|
||||
|
||||
|
||||
|
||||
// Print every unique row
|
||||
for (size_t i = 0; i < row_count; i++) {
|
||||
if (!seen[i]) {
|
||||
PrintMatrixRow(&matrix, i);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef RELEASE
|
||||
// Free all the mmeory so the sanitizer is happy.
|
||||
free(seen);
|
||||
free(cg_buf);
|
||||
free(p_buf);
|
||||
PermutationFree(&a_in_perm);
|
||||
PermutationFree(&b_in_perm);
|
||||
for (size_t i = 0; i < a_in; i++) {
|
||||
PermutationFree(a_out_perms + i);
|
||||
}
|
||||
free(a_out_perms);
|
||||
for (size_t i = 0; i < b_in; i++) {
|
||||
PermutationFree(b_out_perms + i);
|
||||
}
|
||||
free(b_out_perms);
|
||||
MatrixFree(&matrix);
|
||||
#endif
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -166,4 +166,8 @@ matrix_t ParseMatrix(size_t row_len) {
|
|||
compact_buffers(&matrix);
|
||||
|
||||
return matrix;
|
||||
}
|
||||
|
||||
void MatrixFree(matrix_t *matrix) {
|
||||
free(matrix->head);
|
||||
}
|
Loading…
Reference in New Issue