corrigé free

This commit is contained in:
Naej 2016-12-27 22:26:06 +01:00
parent 0dfa280bfc
commit 98e08eab35
2 changed files with 16 additions and 9 deletions

View File

@ -83,7 +83,7 @@ bool CreateMatrixElem(Matrix matrix, int ColPos, int RowPos){
} else if (Col->data->rowIndex > RowPos){ } else if (Col->data->rowIndex > RowPos){
elem->nextRow = Col->data; elem->nextRow = Col->data;
Col->data = elem; Col->data = elem;
} else { } else {NMWZxm5uQt
tmp = Col->data; tmp = Col->data;
while (tmp->nextRow != NULL && tmp->nextRow->rowIndex < RowPos){ while (tmp->nextRow != NULL && tmp->nextRow->rowIndex < RowPos){
tmp=tmp->nextRow; tmp=tmp->nextRow;
@ -295,18 +295,22 @@ bool RecursiveFreeCol(Matrix matrix, cellElement * elem){
Matrix freeMatrix(Matrix matrix){ Matrix freeMatrix(Matrix matrix){
ListElement * current = NULL; int i = 0;
int j = 0;
printf("\n---FREE MATRIX---\n");
matrix.colCount = 0; for (i=0;i<matrix.rowCount;i++){
matrix.rowCount = 0; for (j=0;j<matrix.colCount;j++){
SetCellValue(matrix,j,i,false);
if (matrix.cols != NULL){
current= matrix.cols->head;
while (current != NULL){
RecursiveFreeCol(matrix,current->data);
current = current->next;
} }
} }
printf("---END OF MATRIX---\n\n");
FreeList(matrix.cols); FreeList(matrix.cols);
FreeList(matrix.rows); FreeList(matrix.rows);
return matrix; return matrix;

3
main.c
View File

@ -34,6 +34,9 @@ int main(int argc, char **argv){
freeMatrix(m2); freeMatrix(m2);
m2 = rowSequenceOnMatrix(matrix, AND); m2 = rowSequenceOnMatrix(matrix, AND);
BasicPrintMatrix(m2); BasicPrintMatrix(m2);
/*sumMatrix(matrix,m2);*/
freeMatrix(m2); freeMatrix(m2);
freeMatrix(matrix); freeMatrix(matrix);