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

Function unpack

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

Source from the content-addressed store, hash-verified

133
134
135static int unpack (lua_State *L) {
136 int i, e;
137 unsigned int n;
138 luaL_checktype(L, 1, LUA_TTABLE);
139 i = luaL_optint(L, 2, 1);
140 e = luaL_opt(L, luaL_checkint, 3, luaL_len(L, 1));
141 if (i > e) return 0; /* empty range */
142 n = (unsigned int)e - (unsigned int)i; /* number of elements minus 1 */
143 if (n > (INT_MAX - 10) || !lua_checkstack(L, ++n))
144 return luaL_error(L, "too many results to unpack");
145 lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */
146 while (i++ < e) /* push arg[i + 1...e] */
147 lua_rawgeti(L, 1, i);
148 return n;
149}
150
151/* }====================================================== */
152

Callers

nothing calls this directly

Calls 5

luaL_lenFunction · 0.85
luaL_checktypeFunction · 0.70
lua_checkstackFunction · 0.70
luaL_errorFunction · 0.70
lua_rawgetiFunction · 0.70

Tested by

no test coverage detected