MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / luaC_separateudata

Function luaC_separateudata

Source/Misc/lua/src/lua.c:6130–6157  ·  view source on GitHub ↗

move `dead' udata that need finalization to list `tmudata' */

Source from the content-addressed store, hash-verified

6128
6129/* move `dead' udata that need finalization to list `tmudata' */
6130size_t luaC_separateudata (lua_State *L, int all) {
6131global_State *g = G(L);
6132size_t deadmem = 0;
6133GCObject **p = &g->mainthread->next;
6134GCObject *curr;
6135while ((curr = *p) != NULL) {
6136if (!(iswhite(curr) || all) || isfinalized(gco2u(curr)))
6137p = &curr->gch.next; /* don't bother with them */
6138else if (fasttm(L, gco2u(curr)->metatable, TM_GC) == NULL) {
6139markfinalized(gco2u(curr)); /* don't need finalization */
6140p = &curr->gch.next;
6141}
6142else { /* must call its gc method */
6143deadmem += sizeudata(gco2u(curr));
6144markfinalized(gco2u(curr));
6145*p = curr->gch.next;
6146/* link `curr' at the end of `tmudata' list */
6147if (g->tmudata == NULL) /* list is empty? */
6148g->tmudata = curr->gch.next = curr; /* creates a circular list */
6149else {
6150curr->gch.next = g->tmudata->gch.next;
6151g->tmudata->gch.next = curr;
6152g->tmudata = curr;
6153}
6154}
6155}
6156return deadmem;
6157}
6158
6159
6160static int traversetable (global_State *g, Table *h) {

Callers 2

atomicFunction · 0.85
lua_closeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected