From 73c2b00a10c5786ddeeacc915e233fd4df1c9321 Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Sat, 11 Oct 2025 22:19:00 +0200 Subject: fix: evalexpr & tinyprintf contenaient toute la piscine --- rushs/evalexpr/src/fifo_setup_destroy.c | 44 +++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 rushs/evalexpr/src/fifo_setup_destroy.c (limited to 'rushs/evalexpr/src/fifo_setup_destroy.c') diff --git a/rushs/evalexpr/src/fifo_setup_destroy.c b/rushs/evalexpr/src/fifo_setup_destroy.c new file mode 100644 index 0000000..0f99ad0 --- /dev/null +++ b/rushs/evalexpr/src/fifo_setup_destroy.c @@ -0,0 +1,44 @@ +#include + +#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->data); + free(l); + l = tmp; + } + if (fifo->tail) + { + free(fifo->tail->data); + free(fifo->tail); + } + + fifo->head = NULL; + fifo->tail = NULL; + fifo->size = 0; +} + +void fifo_destroy(struct fifo *fifo) +{ + fifo_clear(fifo); + free(fifo); +} -- cgit v1.2.3