1
0
mirror of https://gitlab.com/klmp200/LO27.git synced 2024-11-29 22:54:14 +00:00

en fait il n'y avait pas de bug sur le point abordé ds le commit precedent, commence free matrix, necessite une mise au pt avec sli

This commit is contained in:
Naej 2016-12-24 16:07:50 +01:00
parent db8322f504
commit 6c6bd307f8
5 changed files with 31 additions and 8 deletions

View File

@ -16,7 +16,6 @@ cellElement * CreateCellElem(){
printf("---Created cellElement---\n"); printf("---Created cellElement---\n");
elem->value = true;
elem->nextCol = NULL; elem->nextCol = NULL;
elem->nextRow = NULL; elem->nextRow = NULL;
@ -132,6 +131,8 @@ void FreeCellElement(cellElement* element) {
if (element != NULL){ if (element != NULL){
free(element); free(element);
}else{
printf("Cant free NULL");
} }
element = NULL; element = NULL;
} }

View File

@ -32,8 +32,6 @@ struct cellElement {
int colIndex; int colIndex;
int rowIndex; int rowIndex;
bool value;
struct cellElement * nextCol; struct cellElement * nextCol;
struct cellElement * nextRow; struct cellElement * nextRow;

View File

@ -103,7 +103,7 @@ bool CreateMatrixElem(Matrix matrix, int ColPos, int RowPos){
if (error != 0){ if (error != 0){
free(elem); FreeCellElement(elem);
return true; return true;
}else{ }else{
return false; return false;
@ -247,3 +247,19 @@ void BasicPrintMatrix(Matrix matrix){
printf("---END OF MATRIX---\n\n"); printf("---END OF MATRIX---\n\n");
} }
Matrix freeMatrix(Matrix matrix){
matrix.colCount = 0;
matrix.rowCount = 0;
/*il faut free les cellElements car FreeList ne peut pas le faire*/
FreeList(matrix.cols);
FreeList(matrix.rows);
return matrix;
}
/* todos :
*finir le freeMatrix
*chasser les bugs
*ecrire doc
*faire un print + opti pour que sli l'adapte avec sdl
*/

View File

@ -79,5 +79,7 @@ Matrix SetMatrixDim(Matrix matrix,int nbCols,int nbRows);
void BasicPrintMatrix(Matrix matrix); void BasicPrintMatrix(Matrix matrix);
Matrix freeMatrix(Matrix matrix);
#endif #endif

12
main.c
View File

@ -15,17 +15,23 @@ int main(int argc, char **argv){
int Rule = 256; int Rule = 256;
int N = 1; int N = 1;
applyRules(matrix,Rule,N); applyRules(matrix,Rule,N);
matrix = SetMatrixDim(matrix,1,2); matrix = SetMatrixDim(matrix,3,3);
BasicPrintMatrix(matrix); BasicPrintMatrix(matrix);
SetCellValue(matrix,0,0,true); SetCellValue(matrix,0,0,true);
SetCellValue(matrix,0,0,true); SetCellValue(matrix,0,1,true);
SetCellValue(matrix,0,2,true);
BasicPrintMatrix(matrix); BasicPrintMatrix(matrix);
SetCellValue(matrix,0,0,false); SetCellValue(matrix,0,0,false);
SetCellValue(matrix,0,0,false); SetCellValue(matrix,0,1,false);
BasicPrintMatrix(matrix); BasicPrintMatrix(matrix);
freeMatrix(matrix);
return 0; return 0;
} }
/* todo
*modifier DeleteListContent avec sli
*/