MCPcopy Create free account
hub / github.com/WheretIB/nullc / Alloc

Method Alloc

NULLC/translation/runtime.cpp:1127–1155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers 1

AllocObjectMethod · 0.45

Calls 2

push_backMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected