summaryrefslogtreecommitdiff
path: root/graphs/piscine/generic_void_list/list.h
blob: a1bc035bbc16304dac5bfda3a3c4e3cef41be896 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef LIST_H
#define LIST_H

#include <stddef.h>

struct list
{
    void *data;
    struct list *next;
};

/*
** Insert a node containing `value` at the beginning of the list.
** Return `NULL` if an error occurred.
*/
struct list *list_prepend(struct list *list, const void *value,
                          size_t data_size);

/*
** Return the length of the list.
** Return `0` if the list is empty.
*/
size_t list_length(struct list *list);

/*
** Release the memory used by the list.
** Does nothing if `list` is `NULL`.
*/
void list_destroy(struct list *list);

#endif /* !LIST_H */