MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / sweeplist

Function sweeplist

3rd/lua-5.4.3/src/lgc.c:816–837  ·  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

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

Callers 2

sweeptoliveFunction · 0.85
sweepstepFunction · 0.85

Calls 1

freeobjFunction · 0.85

Tested by

no test coverage detected