libbbb
1.2.1
Groups common code used in some applications and libraries.
libbbb
Classes
Files
File List
src
antenna
autothread
backjob
bytebuffer
core
doevents
dynstack
jobinterf
lists
list2d.cc
list2d.h
lnklst.h
markup
memtrack
refcount
rexscript
templates
timer
usermsg
varmap
File Members
•
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
lnklst.h
Go to the documentation of this file.
1
/* ========================================================================= */
2
/* ------------------------------------------------------------------------- */
/*
12
13
14
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15
Please read COPYING and README files in root folder
16
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17
*/
18
/* ------------------------------------------------------------------------- */
19
/* ========================================================================= */
20
#ifndef __LNKLST_INC__
21
#define __LNKLST_INC__
22
#ifdef __cplusplus
23
extern
"C"
{
24
#endif
25
//
26
//
27
//
28
//
29
/* INCLUDES ------------------------------------------------------------ */
30
31
/* INCLUDES ============================================================ */
32
//
33
//
34
//
35
//
36
/* DEFINITIONS --------------------------------------------------------- */
37
38
42
struct
_LnkLst
{
43
44
48
struct
_LnkLst
*
p_prev_
;
49
50
54
struct
_LnkLst
*
p_next_
;
55
56
57
};
/* struct LnkLst */
58
typedef
struct
_LnkLst
LnkLst
;
59
60
61
62
63
#define LnkLst_Prepend(p_head, p_new) \
64
assert( p_new != NULL ); \
65
p_new->p_prev_ = NULL; \
66
p_new->p_next_ = ((LnkLst*)p_head); \
67
if ( p_head != NULL ) \
68
{ \
69
assert( ((LnkLst*)p_head)->p_prev_ == NULL ); \
70
((LnkLst*)p_head)->p_prev_ = p_new; \
71
} \
72
((LnkLst*)p_head) = p_new;
73
74
75
#define LnkLst_Extract(p_head, p_it) \
76
assert( ((LnkLst*)p_it) != NULL ); \
77
assert( p_head != NULL ); \
78
if ( ((LnkLst*)p_it)->p_next_ != NULL ) \
79
{ \
80
((LnkLst*)p_it)->p_next_->p_prev_ = ((LnkLst*)p_it)->p_prev_; \
81
} \
82
if ( ((LnkLst*)p_it)->p_prev_ == NULL ) \
83
{ \
84
((LnkLst*)p_head) = ((LnkLst*)p_it)->p_next_; \
85
} \
86
else
/* ( ((LnkLst*)p_it)->p_prev_ != NULL ) */
\
87
{ \
88
((LnkLst*)p_it)->p_prev_->p_next_ = ((LnkLst*)p_it)->p_next_; \
89
}
90
91
92
93
#define LnkLst_Append(p_head, p_tail, p_new) \
94
assert( ((LnkLst*)p_it) != NULL ); \
95
p_new->p_next_ = NULL; \
96
if ( p_tail == NULL ) \
97
{ \
98
assert( p_head == NULL ); \
99
((LnkLst*)p_head) = p_new; \
100
p_new->p_prev_ = NULL; \
101
} \
102
else \
103
{ \
104
assert( p_head != NULL ); \
105
p_tail->p_next_ = p_new; \
106
p_new->p_prev_ = p_tail; \
107
} \
108
p_tail = p_new;
109
110
111
#define LnkLstT_Prepend(p_head, p_tail, p_new) \
112
assert( p_new != NULL ); \
113
p_new->p_prev_ = NULL; \
114
p_new->p_next_ = ((LnkLst*)p_head); \
115
if ( p_head == NULL ) \
116
{ \
117
assert( p_tail == NULL ); \
118
p_tail = p_new; \
119
} \
120
else
/* ( p_head != NULL ) */
\
121
{ \
122
assert( p_tail != NULL ); \
123
assert( ((LnkLst*)p_head)->p_prev_ == NULL ); \
124
((LnkLst*)p_head)->p_prev_ = p_new; \
125
} \
126
p_head = p_new;
127
128
#define LnkLstT_Extract(p_head, p_tail, p_it) \
129
assert( ((LnkLst*)p_it) != NULL ); \
130
assert( p_head != NULL ); \
131
assert( p_tail != NULL ); \
132
if ( ((LnkLst*)p_it)->p_next_ == NULL ) \
133
{ \
134
assert( p_tail == ((LnkLst*)p_it) ); \
135
p_tail = ((LnkLst*)p_it)->p_prev_; \
136
} \
137
else \
138
{ \
139
((LnkLst*)p_it)->p_next_->p_prev_ = ((LnkLst*)p_it)->p_prev_; \
140
} \
141
if ( ((LnkLst*)p_it)->p_prev_ == NULL ) \
142
{ \
143
assert( p_head == p_it) ); \
144
((LnkLst*)p_head) = ((LnkLst*)p_it)->p_next_; \
145
} \
146
else
/* ( ((LnkLst*)p_it)->p_prev_ != NULL ) */
\
147
{ \
148
((LnkLst*)p_it)->p_prev_->p_next_ = (LnkLst*)p_it->p_next_; \
149
}
150
151
152
/* DEFINITIONS ========================================================= */
153
//
154
//
155
//
156
//
157
/* DATA ---------------------------------------------------------------- */
158
159
/* DATA ================================================================ */
160
//
161
//
162
//
163
//
164
/* FUNCTIONS ----------------------------------------------------------- */
165
169
int
LL_index (
170
LnkLst
* p_first,
171
LnkLst
* p_item
172
);
173
174
175
/* FUNCTIONS =========================================================== */
176
//
177
//
178
//
179
//
180
#ifdef __cplusplus
181
}
// extern "c"
182
#endif
183
#endif // __LNKLST_INC__
184
/* ------------------------------------------------------------------------- */
185
/* ========================================================================= */
src
lists
lnklst.h
Generated on Thu Aug 8 2013 20:10:33 for libbbb by
1.8.3.1