Mercurial > hg > Gears > GearsAgda
view src/llrb/llrbContext.c @ 23:868c2918b634
Non Destructive llrb
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 30 Apr 2015 19:07:23 +0900 |
parents | 4c3c0ad4a75d |
children | 7494c0b87ec4 |
line wrap: on
line source
#include <stdlib.h> #include "llrbContext.h" extern __code code1(struct Context*); extern __code code2(struct Context*); extern __code code3(struct Context*); extern __code code4(struct Context*); extern __code code5(struct Context*); extern __code meta(struct Context*); extern __code allocate(struct Context*); extern __code put(struct Context*); extern __code initNode(struct Context*); extern __code compare(struct Context*); extern __code insert(struct Context*); extern __code insertDown(struct Context*); extern __code insertUp(struct Context*); extern __code exit_code(struct Context*); __code initLLRBContext(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->codeNum = Exit; context->code[Code1] = code1; context->code[Code2] = code2; context->code[Code3] = code3; context->code[Code4] = code4; context->code[Code5] = code5; context->code[Allocator] = allocate; context->code[Put] = put; context->code[InitNode] = initNode; context->code[Compare] = compare; context->code[Insert] = insert; /* context->code[InsertD] = insertDown; */ /* context->code[InsertU] = insertUp; */ context->code[Exit] = exit_code; context->heap = context->heap_start; context->data[Allocate] = context->heap; context->heap += sizeof(struct Allocate); context->data[Tree] = context->heap; context->heap += sizeof(struct Tree); context->dataNum = Tree; context->root = 0; context->current = 0; }