LICK
 All Data Structures Files Functions Variables Enumerations Enumerator
llist.h
Go to the documentation of this file.
1 
6 #pragma once
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10 
11 #include <stdlib.h>
12 
13 typedef struct node_t node_t;
14 typedef void (*free_list_item_f)(void *);
15 
19 struct node_t {
21  void *val;
24 };
25 
32 node_t *new_node(void *val, node_t *next);
38 size_t list_length(node_t *lst);
53 node_t *list_sort(node_t *lst, int (*compare)(const void *a, const void *b));
62 void free_list(node_t *n, free_list_item_f free_fn);
63 
64 #ifdef __cplusplus
65 }
66 #endif
node_t * list_sort(node_t *lst, int(*compare)(const void *a, const void *b))
sort a list
Definition: llist.c:53
size_t list_length(node_t *lst)
find the length of a linked list
Definition: llist.c:12
A linked list node.
Definition: llist.h:19
void free_list(node_t *n, free_list_item_f free_fn)
free a list, freeing all elements along the way
Definition: llist.c:65
node_t * list_reverse(node_t *lst)
reverse a list
Definition: llist.c:21
node_t * new_node(void *val, node_t *next)
create a new node, and add it to the start of a list
Definition: llist.c:5
void * val
the current element value
Definition: llist.h:21
node_t * next
the next node in the linked list, or NULL if there are no more elements
Definition: llist.h:23