Mercurial > hg > Members > kent > CbCTaskManager
view DataSegment.cc @ 2:803d6bf22e6d default tip
second commit.
it's far to complete..
author | kent <kent@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Dec 2009 16:19:56 +0900 |
parents | 5b089096921f |
children |
line wrap: on
line source
/* user defined */ DataSegment tree { DataSegment tree first; DataSegment tree second; int v; }; /* replace above to below. */ typedef int32_t DS_offset; struct tree { /* system defined. */ struct { int allocated_size; int size; DS_offset parent; } /* user defined. */ DS_offset first; DS_offset second; void *v; } tree a = new tree(); newDS(type) { data = malloc(defaultsize); data->allocated_size = defaultsize; data->size = sizeof(type); data->parent = 0; return data; } a->first = othertree; // 完全にコピーされる // 次のように扱われる copyDS(DS a, field fld, DS othertree) { DS top; top = a; while (top->parent!=0) { top = top + top->parent; } DS newspace; //if (top->allocated_size < top->size + othertree->size) realloc(); newspace = top + top->size; top->size += othertree->size; memcpy(newspace, othertree, othertree->size); a->fld = newspace - a; newspace->parent = a - newspace; } *(a->first); *(a + a->first); //deleteはできない #if 0 class DS_offset { uint32_t offset; } /* */ class DataSegmentBase { int allocated_size; int size; DS_offset parent; }; DataSegment tree { DataSegment tree first; DataSegment tree second; int v; }; class tree : DataSegmentBase { DS_offset first; DS_offset second; int v; }; DataSegmentBase::operator new() { } DS_offset::operator =(DataSegmentBase ) { } #endif /* * ------------------------------------- * | Sfsv|first|second| | * ------------------------------------- * */ void main() { DataSegment tree a = new DataSegment tree; a->first = null; a->second = null; a->v = "aiueo"; DataSegment tree top = new DataSegment tree; a->first = a; //a->first = new DataSegment tree; a->first->first = new DataSegment tree; }