1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include "list.h" #include <assert.h> void list_make(list* list, size_t size) { if (size == 0) { return; } assert(list); for (size_t i = 0; i < size; ++i) { list[i].prev = (i == 0 ? 0 : &list[i - 1]); list[i].next = (i == size - 1 ? 0 : &list[i + 1]); } }