source: doc/theses/mike_brooks_MMath/programs/lst-issues-intrusive.run.c @ d987881

Last change on this file since d987881 was 5717495, checked in by Michael Brooks <mlbrooks@…>, 20 months ago

Start of the linked-list chapter.

  • Property mode set to 100644
File size: 423 bytes
Line 
1#include <sys/queue.h>
2#include <stdio.h>
3
4
5
6int main() {
7
8
9
10
11
12
13
14
15
16
17
18
19
20// C
21
22struct req {
23  int pri, rqr;
24  LIST_ENTRY(req) x;
25};
26
27LIST_HEAD(reql, req);
28
29struct reql reqs;
30LIST_INIT(&reqs);
31
32struct req
33  r1 = {1, 42},
34  r2 = {2, 42};
35
36LIST_INSERT_HEAD(
37  &reqs, &r2, x);
38LIST_INSERT_HEAD(
39  &reqs, &r1, x);
40
41
42
43
44
45
46
47
48
49
50
51struct req *cur;
52LIST_FOREACH(cur, &reqs, x)
53    printf("{%d %d} ", cur->pri, cur->rqr);
54printf("\n");
55
56}
Note: See TracBrowser for help on using the repository browser.