1
0
mirror of https://gitlab.com/klmp200/LO27.git synced 2024-07-01 12:28:03 +00:00

tests et complètion des fx

This commit is contained in:
Naej 2016-12-10 03:55:07 +01:00
parent 532fc2cf1f
commit 30e9c36b2d
5 changed files with 70 additions and 40 deletions

View File

@ -8,14 +8,50 @@
#include <CellElement.h> #include <CellElement.h>
int main(int argc, char **argv){ 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){ int AddNextCol(cellElement* tree){
cellElement elem = NULL; cellElement * elem = NULL;
elem = (cellElement*) malloc(sizeof(cellElement)); elem = (cellElement*) malloc(sizeof(cellElement));
if (elem == NULL){ if (elem == NULL){
@ -27,19 +63,20 @@ int AddNextCol(cellElement* tree){
elem->value = true; elem->value = true;
elem->nextCol = NULL; elem->nextCol = NULL;
elem->nextRow = NULL; elem->nextRow = NULL;
if (tree->nextCol == NULL){ if (tree->nextCol == NULL){
tree->nextCol = elem; tree->nextCol = elem;
return 1;
}else{ }else{
return -2; return -2;
} }
return 1;
} }
int AddNextRow(cellElement* tree){ int AddNextRow(cellElement* tree){
cellElement elem = NULL; cellElement * elem = NULL;
elem = (cellElement*) malloc(sizeof(cellElement)); elem = (cellElement*) malloc(sizeof(cellElement));
if (elem == NULL){ if (elem == NULL){
@ -53,19 +90,20 @@ int AddNextRow(cellElement* tree){
elem->nextRow = NULL; elem->nextRow = NULL;
if (tree->nextRow == NULL){ if (tree->nextRow == NULL){
tree->nextRow = elem; tree->nextRow = elem;
return 1;
}else{ }else{
return -2; return -2;
} }
return 1;
} }
void removeNextCol(cellElement* tree){ void removeNextCol(cellElement* tree){
printf("---removeNextCol---\n"); printf("---removeNextCol---\n");
if (tree->nextCol != NULL){ if (tree->nextCol != NULL){
DLinkedListElement* elem = tree->nextCol; cellElement * elem = tree->nextCol;
free(elem); free(elem);
elem = NULL; elem = NULL;
tree->nextCol = NULL;
} }
@ -75,9 +113,10 @@ void removeNextRow(cellElement* tree){
printf("---removeNextRow---\n"); printf("---removeNextRow---\n");
if (tree->nextRow != NULL){ if (tree->nextRow != NULL){
DLinkedListElement* elem = tree->nextRow; cellElement* elem = tree->nextRow;
free(elem); free(elem);
elem =NULL; elem =NULL;
tree->nextRow = NULL;
} }
@ -85,11 +124,13 @@ void removeNextRow(cellElement* tree){
void recursivePrint(cellElement * tree){ void recursivePrint(cellElement * tree){
if (tree != NULL){ if (tree != NULL){
printf("Elem : x: %d y: %d \n",tree->colIndex,tree->rowIndex); printf("Elem : x: %d y: %d \n",tree->colIndex,tree->rowIndex);
if (tree->nextCol != NUll){ if (tree->nextCol != NULL){
recursivePrint(tree->nextCol); recursivePrint(tree->nextCol);
}else if (tree->nextRow != NUll){ }
if (tree->nextRow != NULL){
recursivePrint(tree->nextRow); recursivePrint(tree->nextRow);
}else{ }
if (tree->nextCol == NULL && tree->nextCol == NULL){
printf("leaf\n"); printf("leaf\n");
} }

BIN
CellElemFunc.o Normal file

Binary file not shown.

View File

@ -8,8 +8,8 @@
*/ */
typedef enum Bool{ typedef enum Bool{
true = 1; true = 1,
false = 0; false = 0
} bool; } bool;
@ -39,6 +39,9 @@ struct cellElement {
}; };
typedef struct cellElement cellElement; typedef struct cellElement cellElement;
cellElement * CreateCellElem();
void freeCellElem(cellElement * elem);
int AddNextCol(cellElement* tree); int AddNextCol(cellElement* tree);
int AddNextRow(cellElement* tree); int AddNextRow(cellElement* tree);

BIN
Exe Executable file

Binary file not shown.

View File

@ -1,35 +1,21 @@
CXX = gcc CXX = gcc
TARGET = exe TARGET = Exe
SOURCEFILE = main SOURCEFILE = CellElemFunc
CFLAGS = -Wall -Werror -I. -ansi -pedantic -fpic -g CFLAGS = -Wall -Werror -ansi -pedantic -fpic -I. -g
LIST_LIBRARY = matrix/libMatrix
#Generating the executable #Generating the executable
$(TARGET): $(SOURCEFILE).o $(TARGET): $(SOURCEFILE).o
@echo "Generating the executable" @echo "Generating the executable" $@
$(CXX) $(CFLAGS) $(SOURCEFILE).o -o $(TARGET) $(CXX) $(CFLAGS) $(SOURCEFILE).o -o $@
$(SOURCEFILE).o: $(LIST_LIBRARY).so
@echo "Generating $(SOURCEFILE).o"
$(CXX) $(CFLAGS) -Lmatrix -lmatrix -c $(SOURCEFILE).c -o $@ -LlibMatrix -llibMatrix.so
$(LIST_LIBRARY).so:clean
@echo "Generating libMatrix.so" $@
#gcc matrix.c -I. -Wall -Werror -fpic -shared -o $(LIST_LIBRARY).so
$(CXX) -Wall -Werror -ansi -pedantic -I. matrix.c -o $(LIST_LIBRARY).so -shared -fpic
$(SOURCEFILE).o:
@echo "Generating objectfiles" $@
$(CXX) $(CFLAGS) -c $(SOURCEFILE).c -o $@
#Cleaning the executable #Cleaning the executable
clean: clean:
@echo "Cleaning temporary files and libMatrix.so" @echo "Cleaning temporary files"
rm -rf *.o *- *.so $(TARGET) rm -rf *.o *- *.so $(TARGET)
rm -rf $(LIST_LIBRARY).so
#Generating library
lib:
@echo "Generating libMatrix.so"
$(CXX) -Wall -Werror -ansi -pedantic -I. matrix.c -o $(LIST_LIBRARY).so -shared -fpic
release:
@echo "Generating a release version of the program"
make CFLAGS= '-Wall -Werror -I. -ansi -pedantic -fpic'