aboutsummaryrefslogtreecommitdiff
path: root/list/include/list.h
blob: 945de28efc537a41009d02181a74cde328ad6ddf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/// A doubly linked list.
///
/// This list does not hold user data. Instead, the list can be used as an
/// intrusive list or as part as a more complex data structure.
#pragma once

#include <stddef.h>

typedef struct list list;

typedef struct list {
  list* prev;
  list* next;
} list;

/// Create a new list from an array of `size` items.
void list_make(list* list, size_t size);

/// Iterates over all the items in the list.
#define list_foreach(LIST, iter) \
  for (struct list* iter = LIST; iter; iter = iter->next)