| 193 | } |
| 194 | |
| 195 | void* StompAlloc(int size) |
| 196 | { |
| 197 | //return malloc(size); |
| 198 | |
| 199 | if (gStompInside) |
| 200 | return malloc(size); |
| 201 | if (gSA_CritSect == NULL) |
| 202 | StompInit(); |
| 203 | |
| 204 | AutoCrit autoCrit(*gSA_CritSect); |
| 205 | if (gStompInside) |
| 206 | return malloc(size); |
| 207 | gStompInside = true; |
| 208 | |
| 209 | while (true) |
| 210 | { |
| 211 | for (auto itr = gAllocRanges->rbegin(); itr != gAllocRanges->rend(); itr++) |
| 212 | { |
| 213 | auto& alloc = *itr; |
| 214 | void* result = alloc.Alloc(size); |
| 215 | if (result != NULL) |
| 216 | { |
| 217 | gStompInside = false; |
| 218 | return result; |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | gAllocRanges->resize(gAllocRanges->size() + 1); |
| 223 | } |
| 224 | gStompInside = false; |
| 225 | } |
| 226 | |
| 227 | void StompFree(void* addr) |
| 228 | { |
no test coverage detected