|
|
1.1 root 1: /* insque(3C) routines
2: Copyright (C) 1991 Free Software Foundation, Inc.
3:
4: This file is part of the libiberty library.
5: Libiberty is free software; you can redistribute it and/or
6: modify it under the terms of the GNU Library General Public
7: License as published by the Free Software Foundation; either
8: version 2 of the License, or (at your option) any later version.
9:
10: Libiberty is distributed in the hope that it will be useful,
11: but WITHOUT ANY WARRANTY; without even the implied warranty of
12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: Library General Public License for more details.
14:
15: You should have received a copy of the GNU Library General Public
16: License along with libiberty; see the file COPYING.LIB. If
17: not, write to the Free Software Foundation, Inc., 675 Mass Ave,
18: Cambridge, MA 02139, USA. */
19:
20: /*
21:
22: NAME
23:
24: insque, remque -- insert, remove an element from a queue
25:
26: SYNOPSIS
27:
28: struct qelem {
29: struct qelem *q_forw;
30: struct qelem *q_back;
31: char q_data[];
32: };
33:
34: void insque (struct qelem *elem, struct qelem *pred)
35:
36: void remque (struct qelem *elem)
37:
38: DESCRIPTION
39:
40: Routines to manipulate queues built from doubly linked lists.
41: The insque routine inserts ELEM in the queue immediately after
42: PRED. The remque routine removes ELEM from its containing queue.
43:
44: BUGS
45:
46: */
47:
48:
49: struct qelem {
50: struct qelem *q_forw;
51: struct qelem *q_back;
52: };
53:
54:
55: void
56: insque (elem, pred)
57: struct qelem *elem;
58: struct qelem *pred;
59: {
60: elem -> q_forw = pred -> q_forw;
61: pred -> q_forw -> q_back = elem;
62: elem -> q_back = pred;
63: pred -> q_forw = elem;
64: }
65:
66:
67: void
68: remque (elem)
69: struct qelem *elem;
70: {
71: elem -> q_forw -> q_back = elem -> q_back;
72: elem -> q_back -> q_forw = elem -> q_forw;
73: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.