34
|
1 /* Context definition for list example */
|
|
2
|
|
3 #define ALLOCATE_SIZE 100
|
|
4
|
|
5 enum Code {
|
|
6 Code1,
|
|
7 Code2,
|
|
8 Code3,
|
|
9 Code4,
|
|
10 Code5,
|
|
11 Code6,
|
55
|
12 Code7,
|
34
|
13 Allocator,
|
|
14 Append,
|
|
15 Traverse,
|
|
16 Delete,
|
|
17 Exit,
|
|
18 };
|
|
19
|
|
20 enum UniqueData {
|
|
21 Allocate,
|
|
22 List,
|
|
23 };
|
|
24
|
|
25 struct Context {
|
|
26 int codeNum;
|
|
27 __code (**code) (struct Context *);
|
|
28 void* heap_start;
|
|
29 void* heap;
|
|
30 long dataSize;
|
|
31 int dataNum;
|
|
32 union Data* head;
|
|
33 union Data** data;
|
|
34 };
|
|
35
|
|
36 union Data {
|
|
37 long count;
|
|
38 struct List {
|
55
|
39 struct Element* head;
|
|
40 struct Element* tail;
|
|
41 struct Element* current;
|
34
|
42 } list;
|
|
43 struct Element {
|
|
44 int value;
|
55
|
45 struct Element* next;
|
34
|
46 } element;
|
|
47 struct Allocate {
|
|
48 long size;
|
|
49 enum Code next;
|
|
50 enum Code after_append;
|
|
51 enum Code after_delete;
|
|
52 enum Code after_traverse;
|
|
53 } allocate;
|
|
54 };
|