diff options
author | 3gg <3gg@shellblade.net> | 2021-12-04 16:01:12 -0800 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2021-12-04 16:01:12 -0800 |
commit | f8217d240d598f39f70047f7a623dd46312542c6 (patch) | |
tree | 4e40843d665e388416c1226f739c2b8c0b8da736 /list/src | |
parent | 5f6ea503cdb6ad4a95b679672a1ad324d96c89a5 (diff) |
Initial commit.
Diffstat (limited to 'list/src')
-rw-r--r-- | list/src/list.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/list/src/list.c b/list/src/list.c new file mode 100644 index 0000000..f5b6507 --- /dev/null +++ b/list/src/list.c | |||
@@ -0,0 +1,14 @@ | |||
1 | #include "list.h" | ||
2 | |||
3 | #include <assert.h> | ||
4 | |||
5 | void list_make(list* list, size_t size) { | ||
6 | if (size == 0) { | ||
7 | return; | ||
8 | } | ||
9 | assert(list); | ||
10 | for (size_t i = 0; i < size; ++i) { | ||
11 | list[i].prev = (i == 0 ? 0 : &list[i - 1]); | ||
12 | list[i].next = (i == size - 1 ? 0 : &list[i + 1]); | ||
13 | } | ||
14 | } | ||