1
0
mirror of https://gitlab.com/klmp200/LO27.git synced 2024-11-19 16:23:18 +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>
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");
}

BIN
CellElemFunc.o Normal file

Binary file not shown.

View File

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

BIN
Exe Executable file

Binary file not shown.

View File

@ -1,35 +1,21 @@
CXX = gcc
TARGET = exe
SOURCEFILE = main
CFLAGS = -Wall -Werror -I. -ansi -pedantic -fpic -g
LIST_LIBRARY = matrix/libMatrix
TARGET = Exe
SOURCEFILE = CellElemFunc
CFLAGS = -Wall -Werror -ansi -pedantic -fpic -I. -g
#Generating the executable
$(TARGET): $(SOURCEFILE).o
@echo "Generating the executable"
$(CXX) $(CFLAGS) $(SOURCEFILE).o -o $(TARGET)
$(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
@echo "Generating the executable" $@
$(CXX) $(CFLAGS) $(SOURCEFILE).o -o $@
$(SOURCEFILE).o:
@echo "Generating objectfiles" $@
$(CXX) $(CFLAGS) -c $(SOURCEFILE).c -o $@
#Cleaning the executable
clean:
@echo "Cleaning temporary files and libMatrix.so"
@echo "Cleaning temporary files"
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'