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

Function pack

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

Source from the content-addressed store, hash-verified

116*/
117
118static int pack (lua_State *L) {
119 int n = lua_gettop(L); /* number of elements to pack */
120 lua_createtable(L, n, 1); /* create result table */
121 lua_pushinteger(L, n);
122 lua_setfield(L, -2, "n"); /* t.n = number of elements */
123 if (n > 0) { /* at least one element? */
124 int i;
125 lua_pushvalue(L, 1);
126 lua_rawseti(L, -2, 1); /* insert first element */
127 lua_replace(L, 1); /* move table into index 1 */
128 for (i = n; i >= 2; i--) /* assign other elements */
129 lua_rawseti(L, 1, i);
130 }
131 return 1; /* return table */
132}
133
134
135static int unpack (lua_State *L) {

Callers 2

zstd.cFile · 0.85
mem.hFile · 0.85

Calls 7

lua_gettopFunction · 0.70
lua_createtableFunction · 0.70
lua_pushintegerFunction · 0.70
lua_setfieldFunction · 0.70
lua_pushvalueFunction · 0.70
lua_rawsetiFunction · 0.70
lua_replaceFunction · 0.70

Tested by

no test coverage detected