MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / freeobj

Function freeobj

third-party/lua-5.5.0/src/lgc.c:836–882  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

834
835
836static void freeobj (lua_State *L, GCObject *o) {
837 assert_code(l_mem newmem = gettotalbytes(G(L)) - objsize(o));
838 switch (o->tt) {
839 case LUA_VPROTO:
840 luaF_freeproto(L, gco2p(o));
841 break;
842 case LUA_VUPVAL:
843 freeupval(L, gco2upv(o));
844 break;
845 case LUA_VLCL: {
846 LClosure *cl = gco2lcl(o);
847 luaM_freemem(L, cl, sizeLclosure(cl->nupvalues));
848 break;
849 }
850 case LUA_VCCL: {
851 CClosure *cl = gco2ccl(o);
852 luaM_freemem(L, cl, sizeCclosure(cl->nupvalues));
853 break;
854 }
855 case LUA_VTABLE:
856 luaH_free(L, gco2t(o));
857 break;
858 case LUA_VTHREAD:
859 luaE_freethread(L, gco2th(o));
860 break;
861 case LUA_VUSERDATA: {
862 Udata *u = gco2u(o);
863 luaM_freemem(L, o, sizeudata(u->nuvalue, u->len));
864 break;
865 }
866 case LUA_VSHRSTR: {
867 TString *ts = gco2ts(o);
868 luaS_remove(L, ts); /* remove it from hash table */
869 luaM_freemem(L, ts, sizestrshr(cast_uint(ts->shrlen)));
870 break;
871 }
872 case LUA_VLNGSTR: {
873 TString *ts = gco2ts(o);
874 if (ts->shrlen == LSTRMEM) /* must free external string? */
875 (*ts->falloc)(ts->ud, ts->contents, ts->u.lnglen + 1, 0);
876 luaM_freemem(L, ts, luaS_sizelngstr(ts->u.lnglen, ts->shrlen));
877 break;
878 }
879 default: lua_assert(0);
880 }
881 lua_assert(gettotalbytes(G(L)) == newmem);
882}
883
884
885/*

Callers 4

sweeplistFunction · 0.70
sweep2oldFunction · 0.70
sweepgenFunction · 0.70
deletelistFunction · 0.70

Calls 7

objsizeFunction · 0.85
luaS_sizelngstrFunction · 0.85
luaF_freeprotoFunction · 0.70
freeupvalFunction · 0.70
luaH_freeFunction · 0.70
luaE_freethreadFunction · 0.70
luaS_removeFunction · 0.70

Tested by

no test coverage detected