** Traverse a prototype. (While a prototype is being build, its ** arrays can be larger than needed; the extra slots are filled with ** NULL, so the use of 'markobjectN') */
| 477 | ** NULL, so the use of 'markobjectN') |
| 478 | */ |
| 479 | static int traverseproto (global_State *g, Proto *f) { |
| 480 | int i; |
| 481 | if (f->cache && iswhite(f->cache)) |
| 482 | f->cache = NULL; /* allow cache to be collected */ |
| 483 | markobjectN(g, f->source); |
| 484 | for (i = 0; i < f->sizek; i++) /* mark literals */ |
| 485 | markvalue(g, &f->k[i]); |
| 486 | for (i = 0; i < f->sizeupvalues; i++) /* mark upvalue names */ |
| 487 | markobjectN(g, f->upvalues[i].name); |
| 488 | for (i = 0; i < f->sizep; i++) /* mark nested protos */ |
| 489 | markobjectN(g, f->p[i]); |
| 490 | for (i = 0; i < f->sizelocvars; i++) /* mark local-variable names */ |
| 491 | markobjectN(g, f->locvars[i].varname); |
| 492 | return sizeof(Proto) + sizeof(Instruction) * f->sizecode + |
| 493 | sizeof(Proto *) * f->sizep + |
| 494 | sizeof(TValue) * f->sizek + |
| 495 | sizeof(int) * f->sizelineinfo + |
| 496 | sizeof(LocVar) * f->sizelocvars + |
| 497 | sizeof(Upvaldesc) * f->sizeupvalues; |
| 498 | } |
| 499 | |
| 500 | |
| 501 | static lu_mem traverseCclosure (global_State *g, CClosure *cl) { |