** sweep at most 'count' elements from a list of GCObjects erasing dead ** objects, where a dead object is one marked with the old (non current) ** white; change all non-dead objects back to white, preparing for next ** collection cycle. Return where to continue the traversal or NULL if ** list is finished. */
| 733 | ** list is finished. |
| 734 | */ |
| 735 | static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { |
| 736 | global_State *g = G(L); |
| 737 | int ow = otherwhite(g); |
| 738 | int white = luaC_white(g); /* current white */ |
| 739 | while (*p != NULL && count-- > 0) { |
| 740 | GCObject *curr = *p; |
| 741 | int marked = curr->marked; |
| 742 | if (isdeadm(ow, marked)) { /* is 'curr' dead? */ |
| 743 | *p = curr->next; /* remove 'curr' from list */ |
| 744 | freeobj(L, curr); /* erase 'curr' */ |
| 745 | } |
| 746 | else { /* change mark to 'white' */ |
| 747 | curr->marked = cast_byte((marked & maskcolors) | white); |
| 748 | p = &curr->next; /* go to next element */ |
| 749 | } |
| 750 | } |
| 751 | return (*p == NULL) ? NULL : p; |
| 752 | } |
| 753 | |
| 754 | |
| 755 | /* |
no test coverage detected