Mercurial > hg > Papers > 2016 > kkb-master
view src/initContext.c @ 5:910e143c28e7
modify style
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 09 Feb 2016 17:10:44 +0900 |
parents | 52eec0b77576 |
children |
line wrap: on
line source
#include <stdlib.h> #include "context.h" extern __code code1_stub(struct Context*); extern __code code2_stub(struct Context*); extern __code allocator_stub(struct Context*); extern __code exit_code(struct Context*); __code initContext(struct Context* context, int num) { context->heapLimit = sizeof(union Data)*ALLOCATE_SIZE; context->heapStart = malloc(context->heapLimit); context->heap = context->heapStart; context->codeNum = Exit; context->code = malloc(sizeof(__code*)*ALLOCATE_SIZE); context->data = malloc(sizeof(union Data*)*ALLOCATE_SIZE); context->code[Code1] = code1_stub; context->code[Code2] = code2_stub; context->code[Allocator] = allocator_stub; context->code[Exit] = exit_code; context->data[Allocate] = context->heap; context->heap += sizeof(struct Allocate); context->dataNum = Allocate; }