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

Function separatetobefnz

3rd/lua-5.4.3/src/lgc.c:966–983  ·  view source on GitHub ↗

** Move all unreachable objects (or 'all' objects) that need ** finalization from list 'finobj' to list 'tobefnz' (to be finalized). ** (Note that objects after 'finobjold1' cannot be white, so they ** don't need to be traversed. In incremental mode, 'finobjold1' is NULL, ** so the whole list is traversed.) */

Source from the content-addressed store, hash-verified

964** so the whole list is traversed.)
965*/
966static void separatetobefnz (global_State *g, int all) {
967 GCObject *curr;
968 GCObject **p = &g->finobj;
969 GCObject **lastnext = findlast(&g->tobefnz);
970 while ((curr = *p) != g->finobjold1) { /* traverse all finalizable objects */
971 lua_assert(tofinalize(curr));
972 if (!(iswhite(curr) || all)) /* not being collected? */
973 p = &curr->next; /* don't bother with it */
974 else {
975 if (curr == g->finobjsur) /* removing 'finobjsur'? */
976 g->finobjsur = curr->next; /* correct it */
977 *p = curr->next; /* remove 'curr' from 'finobj' list */
978 curr->next = *lastnext; /* link at the end of 'tobefnz' list */
979 *lastnext = curr;
980 lastnext = &curr->next;
981 }
982 }
983}
984
985
986/*

Callers 2

luaC_freeallobjectsFunction · 0.85
atomicFunction · 0.85

Calls 1

findlastFunction · 0.85

Tested by

no test coverage detected