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

Function luaL_ref

ThirdParty/lua/lua/lauxlib.c:533–551  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

531
532
533LUALIB_API int luaL_ref (lua_State *L, int t) {
534 int ref;
535 if (lua_isnil(L, -1)) {
536 lua_pop(L, 1); /* remove from stack */
537 return LUA_REFNIL; /* 'nil' has a unique fixed reference */
538 }
539 t = lua_absindex(L, t);
540 lua_rawgeti(L, t, freelist); /* get first free element */
541 ref = (int)lua_tointeger(L, -1); /* ref = t[freelist] */
542 lua_pop(L, 1); /* remove it from stack */
543 if (ref != 0) { /* any free element? */
544 lua_rawgeti(L, t, ref); /* remove it from list */
545 lua_rawseti(L, t, freelist); /* (t[freelist] = t[ref]) */
546 }
547 else /* no free elements */
548 ref = (int)lua_rawlen(L, t) + 1; /* get a new reference */
549 lua_rawseti(L, t, ref);
550 return ref;
551}
552
553
554LUALIB_API void luaL_unref (lua_State *L, int t, int ref) {

Callers

nothing calls this directly

Calls 4

lua_absindexFunction · 0.85
lua_rawgetiFunction · 0.85
lua_rawsetiFunction · 0.85
lua_rawlenFunction · 0.85

Tested by

no test coverage detected