PatchworkOS
Loading...
Searching...
No Matches
list.h File Reference
#include "_internal/CONTAINER_OF.h"
#include "_internal/NULL.h"
#include <assert.h>
#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  list_entry_t
 A entry in a doubly linked list. More...
 
struct  list_t
 A doubly linked list. More...
 

Macros

#define LIST_FOR_EACH(elem, list, member)
 Iterates over a list.
 
#define LIST_FOR_EACH_SAFE(elem, temp, list, member)
 Safely iterates over a list, allowing for element removal during iteration.
 
#define LIST_FOR_EACH_REVERSE(elem, list, member)
 Iterates over a list in reverse.
 
#define LIST_FOR_EACH_FROM(elem, start, list, member)
 Iterates over a list starting from a specific element.
 
#define LIST_FOR_EACH_FROM_REVERSE(elem, start, list, member)
 Iterates over a list in reverse order starting from a specific element.
 
#define LIST_FOR_EACH_TO(elem, end, list, member)
 Iterates over a list up to a specific element.
 
#define LIST_FOR_EACH_TO_REVERSE(elem, end, list, member)
 Iterates over a list in reverse order up to a specific element.
 
#define LIST_ENTRY_CREATE(name)
 Creates a list entry initializer.
 
#define LIST_CREATE(name)   (list_t){.head = {.prev = &(name).head, .next = &(name).head, .list = &(name)}, .length = 0}
 Creates a list initializer.
 

Typedefs

typedef struct list list_t
 

Functions

static void list_entry_init (list_entry_t *entry)
 Initializes a list entry.
 
static void list_init (list_t *list)
 Initializes a list.
 
static bool list_contains_entry (list_t *list, list_entry_t *entry)
 Check if an entry belongs to a specific list.
 
static bool list_is_empty (list_t *list)
 Checks if a list is empty.
 
static uint64_t list_length (list_t *list)
 Gets the length of the list.
 
static void list_add (list_t *list, list_entry_t *prev, list_entry_t *next, list_entry_t *entry)
 Adds a new element between two existing list entries.
 
static void list_append (list_t *list, list_entry_t *prev, list_entry_t *entry)
 Appends an entry to the list.
 
static void list_prepend (list_t *list, list_entry_t *head, list_entry_t *entry)
 Prepends an entry to the list.
 
static void list_remove (list_t *list, list_entry_t *entry)
 Removes a list entry from its current list.
 
static void list_push (list_t *list, list_entry_t *entry)
 Pushes an entry to the end of the list.
 
static list_entry_tlist_pop (list_t *list)
 Pops the first entry from the list.
 
static list_entry_tlist_first (list_t *list)
 Gets the first entry in the list without removing it.
 
static list_entry_tlist_last (list_t *list)
 Gets the last entry in the list without removing it.