** clear collected entries from weaktables */
| 349 | ** clear collected entries from weaktables |
| 350 | */ |
| 351 | static void cleartable (GCObject *l) { |
| 352 | while (l) { |
| 353 | Table *h = gco2h(l); |
| 354 | int i = h->sizearray; |
| 355 | lua_assert(testbit(h->marked, VALUEWEAKBIT) || |
| 356 | testbit(h->marked, KEYWEAKBIT)); |
| 357 | if (testbit(h->marked, VALUEWEAKBIT)) { |
| 358 | while (i--) { |
| 359 | TValue *o = &h->array[i]; |
| 360 | if (iscleared(o, 0)) /* value was collected? */ |
| 361 | setnilvalue(o); /* remove value */ |
| 362 | } |
| 363 | } |
| 364 | i = sizenode(h); |
| 365 | while (i--) { |
| 366 | Node *n = gnode(h, i); |
| 367 | if (!ttisnil(gval(n)) && /* non-empty entry? */ |
| 368 | (iscleared(key2tval(n), 1) || iscleared(gval(n), 0))) { |
| 369 | setnilvalue(gval(n)); /* remove value ... */ |
| 370 | removeentry(n); /* remove entry from table */ |
| 371 | } |
| 372 | } |
| 373 | l = h->gclist; |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | |
| 378 | static void freeobj (lua_State *L, GCObject *o) { |
no test coverage detected