MCPcopy Create free account
hub / github.com/DFHack/dfhack / sweeplist

Function sweeplist

depends/lua/src/lgc.c:735–752  ·  view source on GitHub ↗

** sweep at most 'count' elements from a list of GCObjects erasing dead ** objects, where a dead object is one marked with the old (non current) ** white; change all non-dead objects back to white, preparing for next ** collection cycle. Return where to continue the traversal or NULL if ** list is finished. */

Source from the content-addressed store, hash-verified

733** list is finished.
734*/
735static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) {
736 global_State *g = G(L);
737 int ow = otherwhite(g);
738 int white = luaC_white(g); /* current white */
739 while (*p != NULL && count-- > 0) {
740 GCObject *curr = *p;
741 int marked = curr->marked;
742 if (isdeadm(ow, marked)) { /* is 'curr' dead? */
743 *p = curr->next; /* remove 'curr' from list */
744 freeobj(L, curr); /* erase 'curr' */
745 }
746 else { /* change mark to 'white' */
747 curr->marked = cast_byte((marked & maskcolors) | white);
748 p = &curr->next; /* go to next element */
749 }
750 }
751 return (*p == NULL) ? NULL : p;
752}
753
754
755/*

Callers 3

sweeptoliveFunction · 0.85
entersweepFunction · 0.85
sweepstepFunction · 0.85

Calls 1

freeobjFunction · 0.85

Tested by

no test coverage detected