| 405 | |
| 406 | |
| 407 | static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { |
| 408 | GCObject *curr; |
| 409 | global_State *g = G(L); |
| 410 | int deadmask = otherwhite(g); |
| 411 | while ((curr = *p) != NULL && count-- > 0) { |
| 412 | if (curr->gch.tt == LUA_TTHREAD) /* sweep open upvalues of each thread */ |
| 413 | sweepwholelist(L, &gco2th(curr)->openupval); |
| 414 | if ((curr->gch.marked ^ WHITEBITS) & deadmask) { /* not dead? */ |
| 415 | lua_assert(!isdead(g, curr) || testbit(curr->gch.marked, FIXEDBIT)); |
| 416 | makewhite(g, curr); /* make it white (for next cycle) */ |
| 417 | p = &curr->gch.next; |
| 418 | } |
| 419 | else { /* must erase `curr' */ |
| 420 | lua_assert(isdead(g, curr) || deadmask == bitmask(SFIXEDBIT)); |
| 421 | *p = curr->gch.next; |
| 422 | if (curr == g->rootgc) /* is the first element of the list? */ |
| 423 | g->rootgc = curr->gch.next; /* adjust first */ |
| 424 | freeobj(L, curr); |
| 425 | } |
| 426 | } |
| 427 | return p; |
| 428 | } |
| 429 | |
| 430 | |
| 431 | static void checkSizes (lua_State *L) { |