Mercurial > hg > Papers > 2015 > kkb-sigos
comparison paper/source/context.c @ 8:bb5fab31cf41
add source file
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 05 May 2015 17:49:31 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
7:9d4f48d9a22d | 8:bb5fab31cf41 |
---|---|
1 #include <stdlib.h> | |
2 | |
3 #include "context.h" | |
4 | |
5 extern __code code1(struct Context*); | |
6 extern __code code2(struct Context*); | |
7 extern __code allocate(struct Context*); | |
8 | |
9 __code initContext(struct Context* context) { | |
10 context->dataSize = sizeof(union Data)*ALLOCATE_SIZE; | |
11 context->code = malloc(sizeof(__code*)*ALLOCATE_SIZE); | |
12 context->data = malloc(sizeof(union Data*)*ALLOCATE_SIZE); | |
13 context->heap_start = malloc(context->dataSize); | |
14 context->heap = context->heap_start; | |
15 | |
16 context->codeNum = 3; | |
17 context->code[Code1] = code1; | |
18 context->code[Code2] = code2; | |
19 context->code[Allocator] = allocate; | |
20 | |
21 context->dataNum = 2; | |
22 context->data[Allocate] = context->heap; | |
23 context->heap += sizeof(struct Allocate); | |
24 context->data[Tree] = context->heap; | |
25 context->heap += sizeof(struct Tree); | |
26 | |
27 context->root = 0; | |
28 context->current = 0; | |
29 } |