mirror of
https://gitlab.com/klmp200/LO27.git
synced 2025-07-11 03:49:23 +00:00
Deleted files + fixed makefile
This commit is contained in:
16
LibList/CellElement.c
Normal file
16
LibList/CellElement.c
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* @Author: klmp200
|
||||
* @Date: 2016-12-10 01:32:50
|
||||
* @Last Modified by: klmp200
|
||||
* @Last Modified time: 2016-12-10 04:29:48
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <CellElement.h>
|
||||
|
||||
void FreeCellElement(cellElement* element) {
|
||||
if (element != NULL){
|
||||
free(element);
|
||||
}
|
||||
}
|
45
LibList/CellElement.h
Normal file
45
LibList/CellElement.h
Normal file
@ -0,0 +1,45 @@
|
||||
#ifndef CELLELMNT_H
|
||||
#define CELLELMNT_H
|
||||
|
||||
|
||||
/*---bool---
|
||||
*@true : 1
|
||||
*@false : 0
|
||||
*/
|
||||
typedef enum Bool{
|
||||
|
||||
true = 1,
|
||||
false = 0
|
||||
|
||||
} bool;
|
||||
|
||||
|
||||
/*---cellElement---
|
||||
*Pointer on a cell of the matrix
|
||||
*
|
||||
*@colIndex : index (int) of the column of this cell
|
||||
*@rowIndex : index (int) of the row of this cell
|
||||
*
|
||||
*@value : a boolean that is the content of the cell
|
||||
*
|
||||
*@nextCol : pointer on the next cellElement in the same column
|
||||
*@nextRow : pointer on the next cellElement in the same row
|
||||
*
|
||||
*/
|
||||
struct cellElement {
|
||||
|
||||
int colIndex;
|
||||
int rowIndex;
|
||||
|
||||
bool value;
|
||||
|
||||
struct cellElement * nextCol;
|
||||
struct cellElement * nextRow;
|
||||
|
||||
};
|
||||
typedef struct cellElement * cellElement;
|
||||
|
||||
|
||||
void FreeCellElement(cellElement* element);
|
||||
|
||||
#endif
|
30
LibList/Makefile
Normal file
30
LibList/Makefile
Normal file
@ -0,0 +1,30 @@
|
||||
CC=gcc
|
||||
CFLAGS=-Wall -Werror -pedantic -fpic -g
|
||||
|
||||
|
||||
LIBSDIR=-L/usr/lib -L../Libs
|
||||
INCLUDEDIR=-I/usr/include -I.
|
||||
|
||||
#Library variables
|
||||
LIBTARGET=libList.so
|
||||
LIBSOURCE=list CellElement
|
||||
LIBSOURCECFILE=$(LIBSOURCE:=.c)
|
||||
LIBSOURCEOFILE=$(LIBSOURCE:=.o)
|
||||
|
||||
#Generating the library binary
|
||||
$(LIBTARGET): $(LIBSOURCEOFILE)
|
||||
@echo "\n Generating the library binary"
|
||||
mkdir -p ../Libs
|
||||
$(CC) $(CFLAGS) -shared $(LIBSOURCEOFILE) -o ../Libs/$(LIBTARGET)
|
||||
|
||||
#Generating object files
|
||||
.c.o:
|
||||
@echo "\n Generating " $@ " from " $<
|
||||
$(CC) $(CFLAGS) $(INCLUDEDIR) -c -o $@ $<
|
||||
|
||||
#Cleaning
|
||||
clean:
|
||||
@echo "\n Cleaning"
|
||||
rm -rf *.o *.exe *.so
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <CellElment.h>
|
||||
#include <CellElement.h>
|
||||
#include <list.h>
|
||||
|
||||
#define SUCCESS 0
|
||||
@ -36,7 +36,7 @@ int unshift(List *list, cellElement *data){
|
||||
|
||||
ListElement *newElement = malloc(sizeof(*newElement));
|
||||
if (list != NULL && newElement != NULL && newData != NULL){
|
||||
memcpy(newData, data, size);
|
||||
memcpy(newData, data, sizeof(cellElement));
|
||||
newElement->data = newData;
|
||||
|
||||
/* Insert the element at the begining of the list */
|
||||
@ -71,7 +71,7 @@ int push(List *list, cellElement *data){
|
||||
|
||||
ListElement *newElement = malloc(sizeof(*newElement));
|
||||
if(list != NULL && newElement != NULL && newData != NULL){
|
||||
memcpy(newData, data, size);
|
||||
memcpy(newData, data, sizeof(cellElement));
|
||||
newElement->data = newData;
|
||||
newElement->next = NULL;
|
||||
if (list->tail == NULL){
|
||||
@ -145,7 +145,7 @@ int PopPtnList(List *list, ListElement *element){
|
||||
}
|
||||
|
||||
if (element->data != NULL){
|
||||
freeCellElement(element->data);
|
||||
FreeCellElement(element->data);
|
||||
}
|
||||
free(element);
|
||||
list->size = list->size - 1;
|
||||
@ -187,10 +187,10 @@ int DeleteListContent(List *list){
|
||||
current = current->next;
|
||||
|
||||
if (toDelete->data != NULL){
|
||||
freeCellElement(toDelete->data);
|
||||
FreeCellElement(toDelete->data);
|
||||
}
|
||||
|
||||
freeCellElement(toDelete);
|
||||
free(toDelete);
|
||||
}
|
||||
list->head = NULL;
|
||||
list->tail = NULL;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef LIST_H
|
||||
#define LIST_H
|
||||
|
||||
#import <CellElement.h>
|
||||
#include <CellElement.h>
|
||||
|
||||
#define SUCCESS 0
|
||||
#define FAILURE 1
|
||||
@ -41,7 +41,7 @@ int unshift(List* list, cellElement* data);
|
||||
* @param size size of the data
|
||||
* @return status of the operation
|
||||
*/
|
||||
int push(List* list, cellElement* data, int size);
|
||||
int push(List* list, cellElement* data);
|
||||
|
||||
/*
|
||||
* Get an element in a given list
|
||||
|
Reference in New Issue
Block a user