From d5e889c9a890b425cc737b420f1416030d9fca5d Mon Sep 17 00:00:00 2001 From: Dennis Boekholtz <1017359@hr.nl> Date: Sat, 30 Mar 2024 18:28:49 +0100 Subject: [PATCH] begin functie create --- FIFOBuff/FIFOBuffChar.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/FIFOBuff/FIFOBuffChar.c b/FIFOBuff/FIFOBuffChar.c index ba0fdb4..acbb63f 100644 --- a/FIFOBuff/FIFOBuffChar.c +++ b/FIFOBuff/FIFOBuffChar.c @@ -153,7 +153,30 @@ bool buffer_is_empty(void) } bool FIFOBuffChar_create(int ){ + + bool ok = false; + + // Initialize the FIFO buffer + FIFO_FirstElement_p = NULL; + FIFO_LastElement_p = NULL; + FIFO_count = 0; + FIFO_Full = false; + FIFO_FirstElement_p = malloc(sizeof(FIFO_element_t)); + if (FIFO_FirstElement_p == NULL) + { + // Memory allocation failed + FIFO_Full = true; + return false; + } + // Initialize the first element + FIFO_FirstElement_p->value = 0; + FIFO_FirstElement_p->nextElement = NULL; + + // Point the last element to the first one + FIFO_LastElement_p = FIFO_FirstElement_p; + + return true; }