MCPcopy Create free account
hub / github.com/ZDoom/Raze / SweepObjects

Function SweepObjects

source/common/objects/dobjgc.cpp:238–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

236//==========================================================================
237
238static size_t SweepObjects(size_t count)
239{
240 DObject *curr;
241 int deadmask = OtherWhite();
242 size_t swept = 0;
243
244 while ((curr = *SweepPos) != nullptr && count-- > 0)
245 {
246 swept += curr->GetClass()->Size;
247 if ((curr->ObjectFlags ^ OF_WhiteBits) & deadmask) // not dead?
248 {
249 assert(!curr->IsDead() || (curr->ObjectFlags & OF_Fixed));
250 curr->MakeWhite(); // make it white (for next cycle)
251 SweepPos = &curr->ObjNext;
252 }
253 else
254 {
255 assert(curr->IsDead());
256 if (!(curr->ObjectFlags & OF_EuthanizeMe))
257 { // The object must be destroyed before it can be deleted.
258 curr->GCNext = ToDestroy;
259 ToDestroy = curr;
260 SweepPos = &curr->ObjNext;
261 }
262 else
263 { // must erase 'curr'
264 *SweepPos = curr->ObjNext;
265 curr->ObjectFlags |= OF_Cleanup;
266 delete curr;
267 swept += GCDELETECOST;
268 }
269 }
270 }
271 return swept;
272}
273
274//==========================================================================
275//

Callers 1

SingleStepFunction · 0.85

Calls 4

OtherWhiteFunction · 0.85
GetClassMethod · 0.80
IsDeadMethod · 0.80
MakeWhiteMethod · 0.45

Tested by

no test coverage detected