** move all unreachable objects (or 'all' objects) that need ** finalization from list 'finobj' to list 'tobefnz' (to be finalized) */
| 878 | ** finalization from list 'finobj' to list 'tobefnz' (to be finalized) |
| 879 | */ |
| 880 | static void separatetobefnz (global_State *g, int all) { |
| 881 | GCObject *curr; |
| 882 | GCObject **p = &g->finobj; |
| 883 | GCObject **lastnext = findlast(&g->tobefnz); |
| 884 | while ((curr = *p) != NULL) { /* traverse all finalizable objects */ |
| 885 | lua_assert(tofinalize(curr)); |
| 886 | if (!(iswhite(curr) || all)) /* not being collected? */ |
| 887 | p = &curr->next; /* don't bother with it */ |
| 888 | else { |
| 889 | *p = curr->next; /* remove 'curr' from 'finobj' list */ |
| 890 | curr->next = *lastnext; /* link at the end of 'tobefnz' list */ |
| 891 | *lastnext = curr; |
| 892 | lastnext = &curr->next; |
| 893 | } |
| 894 | } |
| 895 | } |
| 896 | |
| 897 | |
| 898 | /* |
no test coverage detected