From ddb7d43143ff664948f27cd2cd4e18bdfcce6118 Mon Sep 17 00:00:00 2001 From: Stefan Zabka Date: Thu, 11 Jun 2020 01:00:56 +0200 Subject: Forgot arena folder --- 04_exercise/arena/arena_list.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 04_exercise/arena/arena_list.h (limited to '04_exercise/arena/arena_list.h') diff --git a/04_exercise/arena/arena_list.h b/04_exercise/arena/arena_list.h new file mode 100644 index 0000000..86bf805 --- /dev/null +++ b/04_exercise/arena/arena_list.h @@ -0,0 +1,36 @@ +// +// Created by stefan on 10.06.20. +// + +#ifndef BETRIEBSYSTEME_ARENA_LIST_H +#define BETRIEBSYSTEME_ARENA_LIST_H + +#include +typedef struct Node { + void * value; + struct Node * next; + struct Node * prev; +} Node; + +typedef struct List { + Node * first; + Node * last; +} List; +// This structure manages an arena / memory slab to be used +typedef struct ArenaList { + List freeList; + List activeList; +} ArenaList; + +//Initializes the node array +ArenaList alInit(Node * arena, size_t size); +// Return -1 if the List is full +int alPush(ArenaList* al, void * value); + +// Return -1 if the Node was already deleted +int alRemove(ArenaList* al, Node * node); + +// Return -1 if the Node was already deleted +int alRemoveElem(ArenaList* al, void * value); + +#endif // BETRIEBSYSTEME_ARENA_LIST_H -- cgit v1.2.3-54-g00ecf