summaryrefslogtreecommitdiff
path: root/rushs/evalexpr/fifo
diff options
context:
space:
mode:
Diffstat (limited to 'rushs/evalexpr/fifo')
-rw-r--r--rushs/evalexpr/fifo/Makefile16
-rw-r--r--rushs/evalexpr/fifo/fifo.h28
-rw-r--r--rushs/evalexpr/fifo/fifo_access.c66
-rw-r--r--rushs/evalexpr/fifo/fifo_setup_destroy.c39
4 files changed, 0 insertions, 149 deletions
diff --git a/rushs/evalexpr/fifo/Makefile b/rushs/evalexpr/fifo/Makefile
deleted file mode 100644
index e5c9374..0000000
--- a/rushs/evalexpr/fifo/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-CC=gcc
-CFLAGS=-std=c99 -Wall -Wextra -Wvla -Werror -pedantic
-
-.PHONY: library clean
-
-library: fifo_access.o fifo_setup_destroy.o
- ar csr libfifo.a $^
-
-fifo_access.o: fifo_access.c
- $(CC) $(CFLAGS) -c -o fifo_access.o fifo_access.c
-
-fifo_setup_destroy.o: fifo_setup_destroy.c
- $(CC) $(CFLAGS) -c -o fifo_setup_destroy.o fifo_setup_destroy.c
-
-clean:
- rm *.o libfifo.a
diff --git a/rushs/evalexpr/fifo/fifo.h b/rushs/evalexpr/fifo/fifo.h
deleted file mode 100644
index c4b0a6f..0000000
--- a/rushs/evalexpr/fifo/fifo.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef FIFO_H
-#define FIFO_H
-
-#include <stddef.h>
-
-struct list
-{
- int data;
- struct list *next;
-};
-
-struct fifo
-{
- struct list *head;
- struct list *tail;
- size_t size;
-};
-
-struct fifo *fifo_init(void);
-size_t fifo_size(struct fifo *fifo);
-void fifo_push(struct fifo *fifo, int elt);
-int fifo_head(struct fifo *fifo);
-void fifo_pop(struct fifo *fifo);
-void fifo_clear(struct fifo *fifo);
-void fifo_destroy(struct fifo *fifo);
-void fifo_print(const struct fifo *fifo);
-
-#endif /* !FIFO_H */
diff --git a/rushs/evalexpr/fifo/fifo_access.c b/rushs/evalexpr/fifo/fifo_access.c
deleted file mode 100644
index 5d31586..0000000
--- a/rushs/evalexpr/fifo/fifo_access.c
+++ /dev/null
@@ -1,66 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "fifo.h"
-
-size_t fifo_size(struct fifo *fifo)
-{
- return fifo->size;
-}
-
-void fifo_push(struct fifo *fifo, int elt)
-{
- struct list *new = malloc(sizeof(struct list));
- if (new == NULL)
- {
- return;
- }
- new->data = elt;
-
- if (fifo_size(fifo) == 0)
- {
- fifo->head = new;
- }
- new->next = NULL;
- if (fifo_size(fifo) != 0)
- {
- fifo->tail->next = new;
- }
- fifo->tail = new;
-
- fifo->size++;
-}
-
-int fifo_head(struct fifo *fifo)
-{
- return fifo->head->data;
-}
-
-void fifo_pop(struct fifo *fifo)
-{
- if (fifo_size(fifo) == 0)
- {
- return;
- }
- if (fifo_size(fifo) == 1)
- {
- free(fifo->head);
- fifo->head = NULL;
- fifo->tail = NULL;
- return;
- }
-
- struct list *tmp = fifo->head->next;
- free(fifo->head);
- fifo->head = tmp;
-
- fifo->size--;
-}
-
-void fifo_print(const struct fifo *fifo)
-{
- for (struct list *l = fifo->head; l; l = l->next)
- {
- printf("%d\n", l->data);
- }
-}
diff --git a/rushs/evalexpr/fifo/fifo_setup_destroy.c b/rushs/evalexpr/fifo/fifo_setup_destroy.c
deleted file mode 100644
index 80820e1..0000000
--- a/rushs/evalexpr/fifo/fifo_setup_destroy.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include <stdlib.h>
-
-#include "fifo.h"
-
-struct fifo *fifo_init(void)
-{
- struct fifo *f = malloc(sizeof(struct fifo));
- if (f == NULL)
- {
- return NULL;
- }
-
- f->size = 0;
- f->head = NULL;
- f->tail = NULL;
-
- return f;
-}
-
-void fifo_clear(struct fifo *fifo)
-{
- for (struct list *l = fifo->head; l != fifo->tail;)
- {
- struct list *tmp = l->next;
- free(l);
- l = tmp;
- }
- free(fifo->tail);
-
- fifo->head = NULL;
- fifo->tail = NULL;
- fifo->size = 0;
-}
-
-void fifo_destroy(struct fifo *fifo)
-{
- fifo_clear(fifo);
- free(fifo);
-}