summaryrefslogtreecommitdiffstats
path: root/04_exercise/arena/arena_list.h
diff options
context:
space:
mode:
Diffstat (limited to '04_exercise/arena/arena_list.h')
-rw-r--r--04_exercise/arena/arena_list.h36
1 files changed, 36 insertions, 0 deletions
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 <stdlib.h>
+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