Mercurial > hg > Papers > 2015 > kkb-sigos
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/paper/source/context.c Tue May 05 17:49:31 2015 +0900 @@ -0,0 +1,29 @@ +#include <stdlib.h> + +#include "context.h" + +extern __code code1(struct Context*); +extern __code code2(struct Context*); +extern __code allocate(struct Context*); + +__code initContext(struct Context* context) { + context->dataSize = sizeof(union Data)*ALLOCATE_SIZE; + context->code = malloc(sizeof(__code*)*ALLOCATE_SIZE); + context->data = malloc(sizeof(union Data*)*ALLOCATE_SIZE); + context->heap_start = malloc(context->dataSize); + context->heap = context->heap_start; + + context->codeNum = 3; + context->code[Code1] = code1; + context->code[Code2] = code2; + context->code[Allocator] = allocate; + + context->dataNum = 2; + context->data[Allocate] = context->heap; + context->heap += sizeof(struct Allocate); + context->data[Tree] = context->heap; + context->heap += sizeof(struct Tree); + + context->root = 0; + context->current = 0; +}