-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.h
46 lines (37 loc) · 967 Bytes
/
list.h
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef __WMWM__LIST_H__
#define __WMWM__LIST_H__
typedef struct list_item list_t;
struct list_item {
void *data;
list_t *prev;
list_t *next;
};
/*
* Move element in item to the head of list mainlist.
*/
void list_to_head(list_t **mainlist, list_t *item);
/*
* Create space for a new item and add it to the head of mainlist.
*
* Returns item or NULL if out of memory.
*/
list_t *list_add(list_t **mainlist);
/*
* Remove item from list mainlist.
*/
void list_remove(list_t **mainlist, list_t *item);
/*
* Free any data in current item and then delete item. Optionally
* update number of items in list if stored != NULL.
*/
void list_erase(list_t **list, int *stored, list_t *item);
/*
* Delete all items in list. Optionally update number of items in list
* if stored != NULL.
*/
void list_erase_all(list_t **list, int *stored);
/*
* Print all items in mainlist on stdout.
*/
void list_print(list_t *mainlist);
#endif /* __WMWM__LIST_H__ */