summaryrefslogtreecommitdiffstats
path: root/04_exercise/arena/arena_list.h
blob: 387f88118ecbe018751e2975c18c71f6650a5089 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//
// 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
// Should we have a free list or just a bit set relative to the size of the slab?
typedef struct ArenaList {
    List freeList;
    List activeList;
    Node * arena;
    size_t size;
} 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