| 166 | |
| 167 | |
| 168 | inline void SubAllocator::GlueFreeBlocks() |
| 169 | { |
| 170 | RARPPM_MEM_BLK s0, * p, * p1; |
| 171 | int i, k, sz; |
| 172 | if (LoUnit != HiUnit) |
| 173 | *LoUnit=0; |
| 174 | for (i=0, s0.next=s0.prev=&s0;i < N_INDEXES;i++) |
| 175 | while ( FreeList[i].next ) |
| 176 | { |
| 177 | p=(RARPPM_MEM_BLK*)RemoveNode(i); |
| 178 | p->insertAt(&s0); |
| 179 | p->Stamp=0xFFFF; |
| 180 | p->NU=Indx2Units[i]; |
| 181 | } |
| 182 | for (p=s0.next;p != &s0;p=p->next) |
| 183 | while ((p1=MBPtr(p,p->NU))->Stamp == 0xFFFF && int(p->NU)+p1->NU < 0x10000) |
| 184 | { |
| 185 | p1->remove(); |
| 186 | p->NU += p1->NU; |
| 187 | } |
| 188 | while ((p=s0.next) != &s0) |
| 189 | { |
| 190 | for (p->remove(), sz=p->NU;sz > 128;sz -= 128, p=MBPtr(p,128)) |
| 191 | InsertNode(p,N_INDEXES-1); |
| 192 | if (Indx2Units[i=Units2Indx[sz-1]] != sz) |
| 193 | { |
| 194 | k=sz-Indx2Units[--i]; |
| 195 | InsertNode(MBPtr(p,sz-k),k-1); |
| 196 | } |
| 197 | InsertNode(p,i); |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | void* SubAllocator::AllocUnitsRare(int indx) |
| 202 | { |