From 0a6c7524e0efbc9f277733410ce0f994ec59dfb2 Mon Sep 17 00:00:00 2001 From: Naej Date: Sat, 24 Dec 2016 13:39:14 +0100 Subject: [PATCH] fix suppr --- LibAutomaton/matrix.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/LibAutomaton/matrix.c b/LibAutomaton/matrix.c index 6bb6480..6896a18 100644 --- a/LibAutomaton/matrix.c +++ b/LibAutomaton/matrix.c @@ -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;