MCPcopy Create free account
hub / github.com/DFHack/dfhack / lua_newstate

Function lua_newstate

depends/lua/src/lstate.c:295–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

luaL_newstateFunction · 0.85

Calls 5

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

Tested by

no test coverage detected