** Move all unreachable objects (or 'all' objects) that need ** finalization from list 'finobj' to list 'tobefnz' (to be finalized). ** (Note that objects after 'finobjold' cannot be white, so they ** don't need to be traversed. In incremental mode, 'finobjold' is NULL, ** so the whole list is traversed.) */
| 901 | ** so the whole list is traversed.) |
| 902 | */ |
| 903 | static void separatetobefnz (global_State *g, int all) { |
| 904 | GCObject *curr; |
| 905 | GCObject **p = &g->finobj; |
| 906 | GCObject **lastnext = findlast(&g->tobefnz); |
| 907 | while ((curr = *p) != g->finobjold) { /* traverse all finalizable objects */ |
| 908 | lua_assert(tofinalize(curr)); |
| 909 | if (!(iswhite(curr) || all)) /* not being collected? */ |
| 910 | p = &curr->next; /* don't bother with it */ |
| 911 | else { |
| 912 | if (curr == g->finobjsur) /* removing 'finobjsur'? */ |
| 913 | g->finobjsur = curr->next; /* correct it */ |
| 914 | *p = curr->next; /* remove 'curr' from 'finobj' list */ |
| 915 | curr->next = *lastnext; /* link at the end of 'tobefnz' list */ |
| 916 | *lastnext = curr; |
| 917 | lastnext = &curr->next; |
| 918 | } |
| 919 | } |
| 920 | } |
| 921 | |
| 922 | |
| 923 | /* |
no test coverage detected