MCPcopy Create free account
hub / github.com/BigPig0/RelayLive / lua_newstate

Function lua_newstate

ThirdParty/lua/lua/lstate.c:293–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

291
292
293LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
294 int i;
295 lua_State *L;
296 global_State *g;
297 LG *l = cast(LG *, (*f)(ud, NULL, LUA_TTHREAD, sizeof(LG)));
298 if (l == NULL) return NULL;
299 L = &l->l.l;
300 g = &l->g;
301 L->next = NULL;
302 L->tt = LUA_TTHREAD;
303 g->currentwhite = bitmask(WHITE0BIT);
304 L->marked = luaC_white(g);
305 preinit_thread(L, g);
306 g->frealloc = f;
307 g->ud = ud;
308 g->mainthread = L;
309 g->seed = makeseed(L);
310 g->gcrunning = 0; /* no GC while building state */
311 g->GCestimate = 0;
312 g->strt.size = g->strt.nuse = 0;
313 g->strt.hash = NULL;
314 setnilvalue(&g->l_registry);
315 luaZ_initbuffer(L, &g->buff);
316 g->panic = NULL;
317 g->version = NULL;
318 g->gcstate = GCSpause;
319 g->gckind = KGC_NORMAL;
320 g->allgc = g->finobj = g->tobefnz = g->fixedgc = NULL;
321 g->sweepgc = NULL;
322 g->gray = g->grayagain = NULL;
323 g->weak = g->ephemeron = g->allweak = NULL;
324 g->twups = NULL;
325 g->totalbytes = sizeof(LG);
326 g->GCdebt = 0;
327 g->gcfinnum = 0;
328 g->gcpause = LUAI_GCPAUSE;
329 g->gcstepmul = LUAI_GCMUL;
330 for (i=0; i < LUA_NUMTAGS; i++) g->mt[i] = NULL;
331 if (luaD_rawrunprotected(L, f_luaopen, NULL) != LUA_OK) {
332 /* memory allocation error: free partial state */
333 close_state(L);
334 L = NULL;
335 }
336 return L;
337}
338
339
340LUA_API void lua_close (lua_State *L) {

Callers 1

luaL_newstateFunction · 0.85

Calls 4

preinit_threadFunction · 0.85
makeseedFunction · 0.85
luaD_rawrunprotectedFunction · 0.85
close_stateFunction · 0.85

Tested by

no test coverage detected