MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / luaL_ref

Function luaL_ref

lua/lauxlib.c:529–549  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

lua_rawgetiFunction · 0.85
lua_tointegerFunction · 0.85
lua_rawsetiFunction · 0.85
lua_objlenFunction · 0.85

Tested by

no test coverage detected