Mercurial > hg > Members > innparusu > Gears
view src/llrb/llrbContext.c @ 42:44914699ee9b
refactoring llrb
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 19 May 2015 05:06:25 +0900 |
parents | 44879c87c2dc |
children | a0a58875c93f |
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 clone(struct Context*); extern __code initNode(struct Context*); extern __code compare(struct Context*); extern __code insert(struct Context*); extern __code rotateLeft(struct Context*); extern __code rotateRight(struct Context*); extern __code colorFlip(struct Context*); extern __code fixUp(struct Context*); extern __code changeReference(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[Clone] = clone; context->code[InitNode] = initNode; context->code[Compare] = compare; context->code[Insert] = insert; context->code[RotateL] = rotateLeft; context->code[RotateR] = rotateRight; context->code[ColorFlip] = colorFlip; context->code[FixUp] = fixUp; context->code[ChangeRef] = changeReference; 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->data[Node] = context->heap; context->heap += sizeof(struct Node); context->data[Next] = context->heap; context->heap += sizeof(enum Code); context->dataNum = Next; struct Tree* tree = &context->data[Tree]->tree; tree->root = 0; tree->current = 0; tree->prev = 0; }