daily update
[binutils.git] / libiberty / insque.c
blobc0c1180d42115eb727dd35b7a687c635388c6c5b
1 /* insque(3C) routines
2 This file is in the public domain. */
4 /*
6 @deftypefn Supplemental void insque (struct qelem *@var{elem}, struct qelem *@var{pred})
7 @deftypefnx Supplemental void remque (struct qelem *@var{elem})
9 Routines to manipulate queues built from doubly linked lists. The
10 @code{insque} routine inserts @var{elem} in the queue immediately
11 after @var{pred}. The @code{remque} routine removes @var{elem} from
12 its containing queue. These routines expect to be passed pointers to
13 structures which have as their first members a forward pointer and a
14 back pointer, like this prototype (although no prototype is provided):
16 @example
17 struct qelem @{
18 struct qelem *q_forw;
19 struct qelem *q_back;
20 char q_data[];
21 @};
22 @end example
24 @end deftypefn
29 struct qelem {
30 struct qelem *q_forw;
31 struct qelem *q_back;
35 void
36 insque (elem, pred)
37 struct qelem *elem;
38 struct qelem *pred;
40 elem -> q_forw = pred -> q_forw;
41 pred -> q_forw -> q_back = elem;
42 elem -> q_back = pred;
43 pred -> q_forw = elem;
47 void
48 remque (elem)
49 struct qelem *elem;
51 elem -> q_forw -> q_back = elem -> q_back;
52 elem -> q_back -> q_forw = elem -> q_forw;