~n-muench/ubuntu/oneiric/open-vm-tools/open-vm-tools.fix-836277

« back to all changes in this revision

Viewing changes to lib/misc/dbllnklst.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-07-30 12:56:49 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090730125649-97sfj5li8axiseoo
Tags: 2009.07.22-179896-2
* Temporarily building without dumbnet, the recently uploaded
  new dumbnet upstream version broke down (Closes: #539006).
* Using more common name to store local debian additions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
 
70
70
 
71
71
/*
72
 
 *----------------------------------------------------------------------
73
 
 *
74
 
 * DblLnkLst_Init --
75
 
 *
76
 
 *    Initialize a member of a doubly linked list
77
 
 *
78
 
 * Result
79
 
 *    None
80
 
 *
81
 
 * Side effects:
82
 
 *    None
83
 
 *
84
 
 *----------------------------------------------------------------------
85
 
 */
86
 
 
87
 
void
88
 
DblLnkLst_Init(DblLnkLst_Links *l) // IN
89
 
{
90
 
   ASSERT(l);
91
 
 
92
 
   l->prev = l->next = l;
93
 
}
94
 
 
95
 
 
96
 
/*
97
 
 *----------------------------------------------------------------------
98
 
 *
99
 
 * DblLnkLst_Link --
100
 
 *
101
 
 *    Merge two doubly linked lists into one
102
 
 *
103
 
 *    The operation is commutative
104
 
 *    The operation is inversible (its inverse is DblLnkLst_Unlink)
105
 
 *
106
 
 * Result
107
 
 *    None
108
 
 *
109
 
 * Side effects:
110
 
 *    None
111
 
 *
112
 
 *----------------------------------------------------------------------
113
 
 */
114
 
 
115
 
void
116
 
DblLnkLst_Link(DblLnkLst_Links *l1, // IN
117
 
               DblLnkLst_Links *l2) // IN
118
 
{
119
 
   DblLnkLst_Links *tmp;
120
 
 
121
 
   ASSERT(l1);
122
 
   ASSERT(l2);
123
 
 
124
 
   (tmp      = l1->prev)->next = l2;
125
 
   (l1->prev = l2->prev)->next = l1;
126
 
    l2->prev = tmp                 ;
127
 
}
128
 
 
129
 
 
130
 
/*
131
 
 *----------------------------------------------------------------------
132
 
 *
133
 
 * DblLnkLst_Unlink --
134
 
 *
135
 
 *    Split one doubly linked list into two
136
 
 *
137
 
 *    No check is performed: the caller must ensure that both members
138
 
 *    belong to the same doubly linked list
139
 
 *
140
 
 *    The operation is commutative
141
 
 *    The operation is inversible (its inverse is DblLnkLst_Link)
142
 
 *
143
 
 * Result
144
 
 *    None
145
 
 *
146
 
 * Side effects:
147
 
 *    None
148
 
 *
149
 
 *----------------------------------------------------------------------
150
 
 */
151
 
 
152
 
void
153
 
DblLnkLst_Unlink(DblLnkLst_Links *l1, // IN
154
 
                 DblLnkLst_Links *l2) // IN
155
 
{
156
 
   DblLnkLst_Links *tmp;
157
 
 
158
 
   ASSERT(l1);
159
 
   ASSERT(l2);
160
 
 
161
 
   tmp       = l1->prev            ;
162
 
   (l1->prev = l2->prev)->next = l1;
163
 
   (l2->prev = tmp     )->next = l2;
164
 
}
165
 
 
166
 
 
167
 
/*
168
 
 *----------------------------------------------------------------------
169
 
 *
170
 
 * DblLnkLst_Unlink1 --
171
 
 *
172
 
 *    Unlink an element from its list.
173
 
 *
174
 
 * Result
175
 
 *    None
176
 
 *
177
 
 * Side effects:
178
 
 *    None
179
 
 *
180
 
 *----------------------------------------------------------------------
181
 
 */
182
 
 
183
 
void
184
 
DblLnkLst_Unlink1(DblLnkLst_Links *l) // IN
185
 
{
186
 
   ASSERT(l);
187
 
 
188
 
   DblLnkLst_Unlink(l, l->next);
189
 
}
190
 
 
191
 
 
192
 
/*
193
 
 *----------------------------------------------------------------------------
194
 
 *
195
 
 * DblLnkLst_IsLinked --
196
 
 *
197
 
 *    Determines whether an element is linked with any other elements.
198
 
 *
199
 
 * Results:
200
 
 *    TRUE if link is linked, FALSE otherwise.
201
 
 *
202
 
 * Side effects:
203
 
 *    None.
204
 
 *
205
 
 *----------------------------------------------------------------------------
206
 
 */
207
 
 
208
 
Bool
209
 
DblLnkLst_IsLinked(DblLnkLst_Links const *l) // IN
210
 
{
211
 
   ASSERT(l);
212
 
 
213
 
   ASSERT((l->prev == l && l->next == l) ||
214
 
          (l->prev != l && l->next != l));
215
 
 
216
 
   /*
217
 
    * A DblLnkLst_Links is either linked to itself (not linked) or linked to
218
 
    * other elements in a list (linked).
219
 
    */
220
 
   return l->prev != l;
221
 
}
222
 
 
223
 
 
224
 
/*
225
 
 *----------------------------------------------------------------------
226
 
 *
227
 
 * DblLnkLst_LinkFirst --
228
 
 *
229
 
 *    Insert 'l' at the beginning of the list anchored at 'head'
230
 
 *
231
 
 * Result
232
 
 *    None
233
 
 *
234
 
 * Side effects:
235
 
 *    None
236
 
 *
237
 
 *----------------------------------------------------------------------
238
 
 */
239
 
 
240
 
void
241
 
DblLnkLst_LinkFirst(DblLnkLst_Links *head, // IN
242
 
                    DblLnkLst_Links *l)    // IN
243
 
{
244
 
   ASSERT(head);
245
 
   ASSERT(l);
246
 
 
247
 
   DblLnkLst_Link(head->next, l);
248
 
}
249
 
 
250
 
 
251
 
/*
252
 
 *----------------------------------------------------------------------
253
 
 *
254
 
 * DblLnkLst_LinkLast --
255
 
 *
256
 
 *    Insert 'l' at the end of the list anchored at 'head'
257
 
 *
258
 
 * Result
259
 
 *    None
260
 
 *
261
 
 * Side effects:
262
 
 *    None
263
 
 *
264
 
 *----------------------------------------------------------------------
265
 
 */
266
 
 
267
 
void
268
 
DblLnkLst_LinkLast(DblLnkLst_Links *head, // IN
269
 
                   DblLnkLst_Links *l)    // IN
270
 
{
271
 
   ASSERT(head);
272
 
   ASSERT(l);
273
 
 
274
 
   DblLnkLst_Link(head, l);
275
 
}
 
72
 * XXX This file is empty because I made all the functions inline.
 
73
 * -- edward
 
74
 */
276
75
 
277
76
 
278
77
#if 0