Commit | Line | Data |
---|---|---|
1479465f GJ |
1 | /* |
2 | * dlist.h - macros for handling doubly linked lists | |
3 | * | |
4 | * Copyright © 1997-1999 Ian Jackson <ijackson@chiark.greenend.org.uk> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | |
18 | */ | |
19 | ||
20 | #ifndef DPKG_DLIST_H | |
21 | #define DPKG_DLIST_H | |
22 | ||
23 | #define LIST_UNLINK_PART(list, node, part) \ | |
24 | do { \ | |
25 | if ((node)->part.prev) \ | |
26 | (node)->part.prev->part.next = (node)->part.next; \ | |
27 | else \ | |
28 | (list).head = (node)->part.next; \ | |
29 | if ((node)->part.next) \ | |
30 | (node)->part.next->part.prev = (node)->part.prev; \ | |
31 | else \ | |
32 | (list).tail = (node)->part.prev; \ | |
33 | } while (0) | |
34 | ||
35 | #define LIST_LINK_TAIL_PART(list, node, part) \ | |
36 | do { \ | |
37 | (node)->part.next = NULL; \ | |
38 | (node)->part.prev = (list).tail; \ | |
39 | if ((list).tail) \ | |
40 | (list).tail->part.next = (node); \ | |
41 | else (list).head = (node); \ | |
42 | (list).tail = (node); \ | |
43 | } while (0) | |
44 | ||
45 | #endif |