diff --git a/CellElemFunc.c b/CellElemFunc.c index 9032683..39105d0 100644 --- a/CellElemFunc.c +++ b/CellElemFunc.c @@ -8,14 +8,50 @@ #include int main(int argc, char **argv){ - - + cellElement * tree = NULL; + tree = CreateCellElem(); + tree->colIndex = 1; + AddNextRow(tree); + tree->nextRow->colIndex = 2; + AddNextCol(tree); + tree->nextCol->colIndex = 3; + recursivePrint(tree); + removeNextRow(tree); + removeNextCol(tree); + + recursivePrint(tree); + + + return 0; } +cellElement * CreateCellElem(){ + cellElement * elem = NULL; + elem = (cellElement*) malloc(sizeof(cellElement)); + + if (elem == NULL){ + return NULL; + } + + printf("---Created cellElement---\n"); + + elem->value = true; + elem->nextCol = NULL; + elem->nextRow = NULL; + + + return elem; +} + +void freeCellElem(cellElement * elem){ + free(elem); + elem = NULL; +} + int AddNextCol(cellElement* tree){ - cellElement elem = NULL; + cellElement * elem = NULL; elem = (cellElement*) malloc(sizeof(cellElement)); if (elem == NULL){ @@ -27,19 +63,20 @@ int AddNextCol(cellElement* tree){ elem->value = true; elem->nextCol = NULL; elem->nextRow = NULL; + if (tree->nextCol == NULL){ tree->nextCol = elem; - return 1; }else{ return -2; } - + + return 1; } int AddNextRow(cellElement* tree){ - cellElement elem = NULL; + cellElement * elem = NULL; elem = (cellElement*) malloc(sizeof(cellElement)); if (elem == NULL){ @@ -53,19 +90,20 @@ int AddNextRow(cellElement* tree){ elem->nextRow = NULL; if (tree->nextRow == NULL){ tree->nextRow = elem; - return 1; }else{ return -2; } + return 1; } void removeNextCol(cellElement* tree){ printf("---removeNextCol---\n"); if (tree->nextCol != NULL){ - DLinkedListElement* elem = tree->nextCol; + cellElement * elem = tree->nextCol; free(elem); - elem =NULL; + elem = NULL; + tree->nextCol = NULL; } @@ -75,9 +113,10 @@ void removeNextRow(cellElement* tree){ printf("---removeNextRow---\n"); if (tree->nextRow != NULL){ - DLinkedListElement* elem = tree->nextRow; + cellElement* elem = tree->nextRow; free(elem); elem =NULL; + tree->nextRow = NULL; } @@ -85,11 +124,13 @@ void removeNextRow(cellElement* tree){ void recursivePrint(cellElement * tree){ if (tree != NULL){ printf("Elem : x: %d y: %d \n",tree->colIndex,tree->rowIndex); - if (tree->nextCol != NUll){ + if (tree->nextCol != NULL){ recursivePrint(tree->nextCol); - }else if (tree->nextRow != NUll){ + } + if (tree->nextRow != NULL){ recursivePrint(tree->nextRow); - }else{ + } + if (tree->nextCol == NULL && tree->nextCol == NULL){ printf("leaf\n"); } diff --git a/CellElemFunc.o b/CellElemFunc.o new file mode 100644 index 0000000..96608af Binary files /dev/null and b/CellElemFunc.o differ diff --git a/Exe b/Exe new file mode 100755 index 0000000..c2c0af9 Binary files /dev/null and b/Exe differ diff --git a/LibList/CellElement.h b/LibList/CellElement.h index c0cd57a..f0ae81f 100644 --- a/LibList/CellElement.h +++ b/LibList/CellElement.h @@ -7,7 +7,11 @@ *@false : 0 */ typedef enum Bool{ +<<<<<<< 0996ce834deca07fbf19d0b5de5f3c8b568185e6:LibList/CellElement.h +======= + +>>>>>>> tests et complètion des fx:CellElement.h true = 1, false = 0 @@ -39,6 +43,9 @@ struct cellElement { }; typedef struct cellElement cellElement; +cellElement * CreateCellElem(); +void freeCellElem(cellElement * elem); + int AddNextCol(cellElement* tree); int AddNextRow(cellElement* tree); diff --git a/Makefile b/Makefile index d7e22c6..6c9e421 100644 --- a/Makefile +++ b/Makefile @@ -54,4 +54,3 @@ clean: rm -rf *.o ./Libs/*.so *.exe $(MAKE) -C LibCell clean $(MAKE) -C LibList clean -