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

Function tremove

freebsd/contrib/openzfs/module/lua/ltablib.c:67–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65
66
67static int tremove (lua_State *L) {
68 int size = aux_getn(L, 1);
69 int pos = luaL_optint(L, 2, size);
70 if (pos != size) /* validate 'pos' if given */
71 luaL_argcheck(L, 1 <= pos && pos <= size + 1, 1, "position out of bounds");
72 lua_rawgeti(L, 1, pos); /* result = t[pos] */
73 for ( ; pos < size; pos++) {
74 lua_rawgeti(L, 1, pos+1);
75 lua_rawseti(L, 1, pos); /* t[pos] = t[pos+1] */
76 }
77 lua_pushnil(L);
78 lua_rawseti(L, 1, pos); /* t[pos] = nil */
79 return 1;
80}
81
82
83static void addfield (lua_State *L, luaL_Buffer *b, int i) {

Callers

nothing calls this directly

Calls 3

lua_rawgetiFunction · 0.70
lua_rawsetiFunction · 0.70
lua_pushnilFunction · 0.70

Tested by

no test coverage detected