| 6407 | |
| 6408 | |
| 6409 | static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { |
| 6410 | GCObject *curr; |
| 6411 | global_State *g = G(L); |
| 6412 | int deadmask = otherwhite(g); |
| 6413 | while ((curr = *p) != NULL && count-- > 0) { |
| 6414 | if (curr->gch.tt == LUA_TTHREAD) /* sweep open upvalues of each thread */ |
| 6415 | sweepwholelist(L, &gco2th(curr)->openupval); |
| 6416 | if ((curr->gch.marked ^ WHITEBITS) & deadmask) { /* not dead? */ |
| 6417 | lua_assert(!isdead(g, curr) || testbit(curr->gch.marked, FIXEDBIT)); |
| 6418 | makewhite(g, curr); /* make it white (for next cycle) */ |
| 6419 | p = &curr->gch.next; |
| 6420 | } |
| 6421 | else { /* must erase `curr' */ |
| 6422 | lua_assert(isdead(g, curr) || deadmask == bitmask(SFIXEDBIT)); |
| 6423 | *p = curr->gch.next; |
| 6424 | if (curr == g->rootgc) /* is the first element of the list? */ |
| 6425 | g->rootgc = curr->gch.next; /* adjust first */ |
| 6426 | freeobj(L, curr); |
| 6427 | } |
| 6428 | } |
| 6429 | return p; |
| 6430 | } |
| 6431 | |
| 6432 | |
| 6433 | static void checkSizes (lua_State *L) { |