** 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.) */
| 964 | ** so the whole list is traversed.) |
| 965 | */ |
| 966 | static 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 | /* |
no test coverage detected