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,
|
|
12 Allocator,
|
|
13 Append,
|
|
14 Traverse,
|
|
15 Delete,
|
|
16 Exit,
|
|
17 };
|
|
18
|
|
19 enum UniqueData {
|
|
20 Allocate,
|
|
21 List,
|
|
22 };
|
|
23
|
|
24 struct Context {
|
|
25 int codeNum;
|
|
26 __code (**code) (struct Context *);
|
|
27 void* heap_start;
|
|
28 void* heap;
|
|
29 long dataSize;
|
|
30 int dataNum;
|
|
31 union Data* head;
|
|
32 union Data** data;
|
|
33 };
|
|
34
|
|
35 union Data {
|
|
36 long count;
|
|
37 struct List {
|
|
38 union Data* head;
|
|
39 union Data* current;
|
|
40 } list;
|
|
41 struct Element {
|
|
42 int value;
|
|
43 union Data* next;
|
|
44 } element;
|
|
45 struct Allocate {
|
|
46 long size;
|
|
47 enum Code next;
|
|
48 enum Code after_append;
|
|
49 enum Code after_delete;
|
|
50 enum Code after_traverse;
|
|
51 } allocate;
|
|
52 };
|