MCPcopy Create free account
hub / github.com/F-Stack/f-stack / luaL_ref

Function luaL_ref

freebsd/contrib/openzfs/module/lua/lauxlib.c:482–500  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

480
481
482LUALIB_API int luaL_ref (lua_State *L, int t) {
483 int ref;
484 if (lua_isnil(L, -1)) {
485 lua_pop(L, 1); /* remove from stack */
486 return LUA_REFNIL; /* `nil' has a unique fixed reference */
487 }
488 t = lua_absindex(L, t);
489 lua_rawgeti(L, t, freelist); /* get first free element */
490 ref = (int)lua_tointeger(L, -1); /* ref = t[freelist] */
491 lua_pop(L, 1); /* remove it from stack */
492 if (ref != 0) { /* any free element? */
493 lua_rawgeti(L, t, ref); /* remove it from list */
494 lua_rawseti(L, t, freelist); /* (t[freelist] = t[ref]) */
495 }
496 else /* no free elements */
497 ref = (int)lua_rawlen(L, t) + 1; /* get a new reference */
498 lua_rawseti(L, t, ref);
499 return ref;
500}
501
502
503LUALIB_API void luaL_unref (lua_State *L, int t, int ref) {

Callers

nothing calls this directly

Calls 5

lua_absindexFunction · 0.85
lua_tointegerFunction · 0.85
lua_rawlenFunction · 0.85
lua_rawgetiFunction · 0.70
lua_rawsetiFunction · 0.70

Tested by

no test coverage detected