fix suppr

This commit is contained in:
Naej 2016-12-24 13:39:14 +01:00
parent 6d3043902c
commit 0a6c7524e0
1 changed files with 18 additions and 5 deletions

View File

@ -128,7 +128,11 @@ int SupprMatrixElem(Matrix matrix, int ColPos, int RowPos){
}
Row = GetElementPos(matrix.rows,RowPos);
if (Row == NULL || Row->data == NULL){
if (Row == NULL){
return -1;
}
if (Row->data == NULL){
RemoveElementPos(matrix.rows,RowPos);
return -1;
}
@ -146,12 +150,19 @@ int SupprMatrixElem(Matrix matrix, int ColPos, int RowPos){
}
}
if (Row->data == NULL){
RemoveElementPos(matrix.rows,RowPos);
}
Col = GetElementPos(matrix.cols,ColPos);
if (Col == NULL|| Col->data == NULL){
if (Col == NULL){
return -2;
}
if (Col->data == NULL){
RemoveElementPos(matrix.cols,ColPos);
return -1;
}
if (Col->data->rowIndex == RowPos){
Col->data = elem->nextRow;
} else {
@ -163,10 +174,12 @@ int SupprMatrixElem(Matrix matrix, int ColPos, int RowPos){
return -4; /* WTF ?? */
} else {
tmp->nextRow = elem->nextRow;
}
}
}
if (Col->data == NULL){
RemoveElementPos(matrix.cols,ColPos);
}
FreeCellElement(elem);
return 1;