| 1125 | } |
| 1126 | |
| 1127 | void* Alloc() |
| 1128 | { |
| 1129 | MySmallBlock* result; |
| 1130 | if(freeBlocks && freeBlocks != &lastBlock) |
| 1131 | { |
| 1132 | result = freeBlocks; |
| 1133 | freeBlocks = freeBlocks->next; |
| 1134 | }else{ |
| 1135 | if(lastNum == countInBlock) |
| 1136 | { |
| 1137 | MyLargeBlock* newPage = (MyLargeBlock*)NULLC::alloc(sizeof(MyLargeBlock)); |
| 1138 | //memset(newPage, 0, sizeof(MyLargeBlock)); |
| 1139 | newPage->next = activePages; |
| 1140 | activePages = newPage; |
| 1141 | lastNum = 0; |
| 1142 | sortedPages.push_back(newPage); |
| 1143 | int index = sortedPages.size() - 1; |
| 1144 | while(index > 0 && sortedPages[index] < sortedPages[index - 1]) |
| 1145 | { |
| 1146 | MyLargeBlock *tmp = sortedPages[index]; |
| 1147 | sortedPages[index] = sortedPages[index - 1]; |
| 1148 | sortedPages[index - 1] = tmp; |
| 1149 | index--; |
| 1150 | } |
| 1151 | } |
| 1152 | result = &activePages->page[lastNum++]; |
| 1153 | } |
| 1154 | return result; |
| 1155 | } |
| 1156 | |
| 1157 | void Free(void* ptr) |
| 1158 | { |
no test coverage detected