7
|
1 /* Context definition */
|
|
2
|
|
3 #define ALLOCATE_SIZE 1024
|
|
4
|
|
5 enum Code {
|
|
6 Code1,
|
|
7 Code2,
|
|
8 Allocator,
|
|
9 };
|
|
10
|
|
11 enum UniqueData {
|
|
12 Allocate,
|
|
13 Tree,
|
|
14 };
|
|
15
|
|
16 struct Context {
|
|
17 int codeNum;
|
|
18 __code (**code) (struct Context *);
|
|
19 void* heap_start;
|
|
20 void* heap;
|
|
21 long dataSize;
|
|
22 int dataNum;
|
|
23 union Data **data;
|
|
24 };
|
|
25
|
|
26 union Data {
|
|
27 struct Tree {
|
|
28 union Data* root;
|
|
29 union Data* current;
|
|
30 union Data* prev;
|
|
31 int result;
|
|
32 } tree;
|
|
33 struct Node {
|
|
34 int key;
|
|
35 int value;
|
|
36 enum Color {
|
|
37 Red,
|
|
38 Black,
|
|
39 } color;
|
|
40 union Data* left;
|
|
41 union Data* right;
|
|
42 } node;
|
|
43 struct Allocate {
|
|
44 long size;
|
|
45 enum Code next;
|
|
46 } allocate;
|
|
47 };
|