Lucciefr
Lua code caving, injection and exploration framework
Main Page
Data Structures
Files
File List
Globals
core
list.h
Go to the documentation of this file.
1
19
/* ---------------------------------------------------------------------------
20
Copyright 2015 by the Lucciefr team
21
22
2015-08-13 [BNO] adapted to Lucciefr (and doxygen comments)
23
2013-05-01 [BNO] initial version
24
*/
25
26
#ifndef LIST_H
27
#define LIST_H
28
31
#define LIST_ITERATE(element, head) \
32
for (element = head; element; element = element->next)
33
35
#define LIST_LAST(element, head) \
36
do { element = head; \
37
while (element) { if (!element->next) break; element = element->next; } \
38
} while (0)
39
42
56
#define LIST_ITERATE_REVERSED(element, head) \
57
LIST_LAST(element, head); \
58
for (; element; element = element->prev)
59
63
#define LIST_MATCH(element, head, condition) \
64
do { \
65
LIST_ITERATE(element, head) { if (condition) break; } \
66
} while (0)
67
69
#define LIST_FIND(element, head, value) \
70
LIST_MATCH(element, head, element == value)
71
73
#define LIST_COUNT(counter, head) \
74
do { __typeof__ (head) LIST_element; \
75
counter = 0; LIST_ITERATE(LIST_element, head) { counter++; } \
76
} while (0)
77
79
#define LIST_APPEND(element, head) \
80
do { __typeof__ (head) LIST_last; \
81
LIST_LAST(LIST_last, head);
/* find last element */
\
82
element->prev = LIST_last; \
83
element->next = NULL; \
84
if (LIST_last) LIST_last->next = element; \
85
else
/* should only happen on (head == NULL) */
head = element; \
86
} while (0)
87
89
#define LIST_DELETE(element, head) \
90
do { __typeof__ (head) LIST_prev = element->prev; \
91
__typeof__ (head) LIST_next = element->next; \
92
if (LIST_next) LIST_next->prev = LIST_prev; \
93
if (LIST_prev) LIST_prev->next = LIST_next; \
94
else
/* should only happen on (element == head) */
head = LIST_next; \
95
} while (0)
96
97
#endif // LIST_H
Generated on Fri Jul 15 2016 17:25:54 for Lucciefr by
1.8.10