diff options
| author | Benedict <benedict@0xb8000.de> | 2017-02-02 00:32:26 +0100 |
|---|---|---|
| committer | Benedict <benedict@0xb8000.de> | 2017-02-21 13:00:27 +0100 |
| commit | 1fd84c7dc70a0a6e6d8651fafa50c51dd697ae77 (patch) | |
| tree | af5de3c7952e071c8e27800c41d9f945fa86c9e7 /lib/test_list.c | |
| parent | 9dcc7348ad53cab8fd9396699de0177bac6729d5 (diff) | |
added random stuff which hasn't beend added because yeah
Diffstat (limited to 'lib/test_list.c')
| -rw-r--r-- | lib/test_list.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/test_list.c b/lib/test_list.c new file mode 100644 index 0000000..7e72fb8 --- /dev/null +++ b/lib/test_list.c @@ -0,0 +1,51 @@ +#include "doublelinkedlist.h" +#include <stdlib.h> +#include <stdio.h> + + +struct in { + int low; + int max; + struct list next; +}; + +int main() +{ + struct in tmp; + struct in tmp2; + struct in tmp3; + struct in tmp4; + struct list *iter, *head; + + tmp.low = 1; + tmp.max = 3; + tmp2.low = 5; + tmp2.max = 9; + tmp3.low = 14; + tmp3.max = 16; + tmp4.low = 23; + tmp4.max = 35; + + LIST_INIT(&tmp.next); + LIST_INIT(&tmp2.next); + LIST_INIT(&tmp3.next); + LIST_INIT(&tmp4.next); + + list_insert_after(&tmp.next, &tmp2.next); + list_insert_after(&tmp2.next, &tmp3.next); + list_insert_after(&tmp3.next, &tmp4.next); + + head = &tmp2.next; + + LIST_TO_END(iter, head) { + struct in *i = CONTAINER_OF(iter, struct in, next); + printf("low: %i, max: %i\n", i->low, i->max); + } + + list_delete(&tmp4.next); + LIST_TO_END(iter, head) { + struct in *i = CONTAINER_OF(iter, struct in, next); + printf("low: %i, max: %i\n", i->low, i->max); + } + +} |
