| 93 | } |
| 94 | |
| 95 | void* Alloc() |
| 96 | { |
| 97 | MySmallBlock* result; |
| 98 | if(freeBlocks && freeBlocks != &lastBlock) |
| 99 | { |
| 100 | result = freeBlocks; |
| 101 | freeBlocks = (MySmallBlock*)((intptr_t)freeBlocks->next & ~NULLC::OBJECT_MASK); |
| 102 | }else{ |
| 103 | if(lastNum == countInBlock) |
| 104 | { |
| 105 | MyLargeBlock* newPage = new(NULLC::alloc(sizeof(MyLargeBlock))) MyLargeBlock; |
| 106 | //memset(newPage, 0, sizeof(MyLargeBlock)); |
| 107 | newPage->next = activePages; |
| 108 | activePages = newPage; |
| 109 | lastNum = 0; |
| 110 | sortedPages.push_back(newPage); |
| 111 | int index = sortedPages.size() - 1; |
| 112 | while(index > 0 && sortedPages[index] < sortedPages[index - 1]) |
| 113 | { |
| 114 | MyLargeBlock *tmp = sortedPages[index]; |
| 115 | sortedPages[index] = sortedPages[index - 1]; |
| 116 | sortedPages[index - 1] = tmp; |
| 117 | index--; |
| 118 | } |
| 119 | } |
| 120 | result = &activePages->page[lastNum++]; |
| 121 | } |
| 122 | return result; |
| 123 | } |
| 124 | |
| 125 | void Free(void* ptr) |
| 126 | { |
no test coverage detected