** move all unreachable objects (or 'all' objects) that need ** finalization from list 'finobj' to list 'tobefnz' (to be finalized) */
| 842 | ** finalization from list 'finobj' to list 'tobefnz' (to be finalized) |
| 843 | */ |
| 844 | static void separatetobefnz (lua_State *L, int all) { |
| 845 | global_State *g = G(L); |
| 846 | GCObject **p = &g->finobj; |
| 847 | GCObject *curr; |
| 848 | GCObject **lastnext = &g->tobefnz; |
| 849 | /* find last 'next' field in 'tobefnz' list (to add elements in its end) */ |
| 850 | while (*lastnext != NULL) |
| 851 | lastnext = &gch(*lastnext)->next; |
| 852 | while ((curr = *p) != NULL) { /* traverse all finalizable objects */ |
| 853 | lua_assert(!isfinalized(curr)); |
| 854 | lua_assert(testbit(gch(curr)->marked, SEPARATED)); |
| 855 | if (!(iswhite(curr) || all)) /* not being collected? */ |
| 856 | p = &gch(curr)->next; /* don't bother with it */ |
| 857 | else { |
| 858 | l_setbit(gch(curr)->marked, FINALIZEDBIT); /* won't be finalized again */ |
| 859 | *p = gch(curr)->next; /* remove 'curr' from 'finobj' list */ |
| 860 | gch(curr)->next = *lastnext; /* link at the end of 'tobefnz' list */ |
| 861 | *lastnext = curr; |
| 862 | lastnext = &gch(curr)->next; |
| 863 | } |
| 864 | } |
| 865 | } |
| 866 | |
| 867 | |
| 868 | /* |
no outgoing calls
no test coverage detected