| 1 | #pragma once
|
|---|
| 2 |
|
|---|
| 3 | typedef char char_t;
|
|---|
| 4 |
|
|---|
| 5 | //######################### HandleNode #########################
|
|---|
| 6 | struct VbyteHeap_t;
|
|---|
| 7 |
|
|---|
| 8 | struct HandleNode_t
|
|---|
| 9 | {
|
|---|
| 10 | char_t* string;
|
|---|
| 11 | unsigned short int length;
|
|---|
| 12 |
|
|---|
| 13 | HandleNode_t* next;
|
|---|
| 14 | HandleNode_t* previous;
|
|---|
| 15 | };
|
|---|
| 16 |
|
|---|
| 17 | static inline void ctor(HandleNode_t* const this);
|
|---|
| 18 | static inline void ctor(HandleNode_t* const this, VbyteHeap_t* heap);
|
|---|
| 19 | static inline void dtor(HandleNode_t* const this);
|
|---|
| 20 |
|
|---|
| 21 | void DeleteNode(HandleNode_t* const this);
|
|---|
| 22 | void AddThisAfter(HandleNode_t* const this, HandleNode_t* other);
|
|---|
| 23 |
|
|---|
| 24 | void MoveThisAfter(HandleNode_t* const this, const HandleNode_t* rhs);
|
|---|
| 25 | void MoveThisBefore(HandleNode_t* const this, const HandleNode_t* rhs);
|
|---|
| 26 |
|
|---|
| 27 | //######################### VbyteHeap #########################
|
|---|
| 28 |
|
|---|
| 29 | struct VbyteHeap
|
|---|
| 30 | {
|
|---|
| 31 | HandleNode_t Header;
|
|---|
| 32 |
|
|---|
| 33 | int NoOfCompactions;
|
|---|
| 34 | int NoOfExtensions;
|
|---|
| 35 | int NoOfReductions;
|
|---|
| 36 |
|
|---|
| 37 | int InitSize;
|
|---|
| 38 | int CurrSize;
|
|---|
| 39 | char_t* StartVbyte;
|
|---|
| 40 | char_t* EndVbyte;
|
|---|
| 41 | void* ExtVbyte;
|
|---|
| 42 | };
|
|---|
| 43 |
|
|---|
| 44 | static inline void ctor(VbyteHeap* const this, int size);
|
|---|
| 45 | static inline void dtor(VbyteHeap* const this);
|
|---|
| 46 |
|
|---|
| 47 | void compaction(VbyteHeap* const this);
|
|---|
| 48 | void garbage(VbyteHeap* const this);
|
|---|
| 49 | void extend(VbyteHeap* const this, int);
|
|---|
| 50 | void reduce(VbyteHeap* const this, int);
|
|---|
| 51 |
|
|---|
| 52 | static inline ctor(HandleNode_t* const this)
|
|---|
| 53 | {
|
|---|
| 54 | this->string = (void*)0;
|
|---|
| 55 | this->length = 0;
|
|---|
| 56 | }
|
|---|
| 57 |
|
|---|
| 58 | static inline ctor(HandleNode_t* const this, VbyteHeap* vh)
|
|---|
| 59 | {
|
|---|
| 60 | this->string = (void*)0;
|
|---|
| 61 | this->length = 0;
|
|---|
| 62 | HandleNode_t* const node = &vh->Header;
|
|---|
| 63 | AddThisAfter(this, node->previous);
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 | static inline dtor(HandleNode_t* const this)
|
|---|
| 67 | {
|
|---|
| 68 | DeleteNode(this);
|
|---|
| 69 | }
|
|---|