26
|
1 __code initLLRBContext(struct Context* context, int num) {
|
|
2 context->heapLimit = sizeof(union Data)*ALLOCATE_SIZE;
|
|
3 context->code = malloc(sizeof(__code*)*ALLOCATE_SIZE);
|
|
4 context->data = malloc(sizeof(union Data*)*ALLOCATE_SIZE);
|
|
5 context->heapStart = malloc(context->heapLimit);
|
|
6
|
|
7 context->codeNum = Exit;
|
|
8
|
|
9 context->code[Code1] = code1_stub;
|
|
10 context->code[Code2] = code2_stub;
|
|
11 context->code[Code3] = code3_stub;
|
|
12 context->code[Code4] = code4;
|
|
13 context->code[Code5] = code5;
|
|
14 context->code[Find] = find;
|
|
15 context->code[Not_find] = not_find;
|
|
16 context->code[Code6] = code6;
|
|
17 context->code[Put] = put_stub;
|
|
18 context->code[Replace] = replaceNode_stub;
|
|
19 context->code[Insert] = insertNode_stub;
|
|
20 context->code[RotateL] = rotateLeft_stub;
|
|
21 context->code[RotateR] = rotateRight_stub;
|
|
22 context->code[InsertCase1] = insert1_stub;
|
|
23 context->code[InsertCase2] = insert2_stub;
|
|
24 context->code[InsertCase3] = insert3_stub;
|
|
25 context->code[InsertCase4] = insert4_stub;
|
|
26 context->code[InsertCase4_1] = insert4_1_stub;
|
|
27 context->code[InsertCase4_2] = insert4_2_stub;
|
|
28 context->code[InsertCase5] = insert5_stub;
|
|
29 context->code[StackClear] = stackClear_stub;
|
|
30 context->code[Exit] = exit_code;
|
|
31
|
|
32 context->heap = context->heapStart;
|
|
33
|
|
34 context->data[Allocate] = context->heap;
|
|
35 context->heap += sizeof(struct Allocate);
|
|
36
|
|
37 context->data[Tree] = context->heap;
|
|
38 context->heap += sizeof(struct Tree);
|
|
39
|
|
40 context->data[Node] = context->heap;
|
|
41 context->heap += sizeof(struct Node);
|
|
42
|
|
43 context->dataNum = Node;
|
|
44
|
|
45 struct Tree* tree = &context->data[Tree]->tree;
|
|
46 tree->root = 0;
|
|
47 tree->current = 0;
|
|
48 tree->deleted = 0;
|
|
49
|
|
50 context->node_stack = stack_init(sizeof(struct Node*), 100);
|
|
51 context->code_stack = stack_init(sizeof(enum Code), 100);
|
|
52 }
|
|
53
|