MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / sweeplist

Function sweeplist

lib/lua/src/lgc.c:824–845  ·  view source on GitHub ↗

** sweep at most 'countin' 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. ('*countout' gets the number of elements traversed.) */

Source from the content-addressed store, hash-verified

822** list is finished. ('*countout' gets the number of elements traversed.)
823*/
824static GCObject **sweeplist (lua_State *L, GCObject **p, int countin,
825 int *countout) {
826 global_State *g = G(L);
827 int ow = otherwhite(g);
828 int i;
829 int white = luaC_white(g); /* current white */
830 for (i = 0; *p != NULL && i < countin; i++) {
831 GCObject *curr = *p;
832 int marked = curr->marked;
833 if (isdeadm(ow, marked)) { /* is 'curr' dead? */
834 *p = curr->next; /* remove 'curr' from list */
835 freeobj(L, curr); /* erase 'curr' */
836 }
837 else { /* change mark to 'white' */
838 curr->marked = cast_byte((marked & ~maskgcbits) | white);
839 p = &curr->next; /* go to next element */
840 }
841 }
842 if (countout)
843 *countout = i; /* number of elements traversed */
844 return (*p == NULL) ? NULL : p;
845}
846
847
848/*

Callers 2

sweeptoliveFunction · 0.85
sweepstepFunction · 0.85

Calls 2

freeobjFunction · 0.85
GFunction · 0.50

Tested by

no test coverage detected