}
sum += lua_tonumber(L, i);
}
lua_pushnumber(L, sum/n); /* first result */
lua_pushnumber(L, sum); /* second result */
return 2; /* number of results */
}
<
lua_checkstack *lua_checkstack()*
>c
int lua_checkstack (lua_State *L, int extra);
<
Ensures that there are at least `extra` free stack slots in the stack.
It returns false if it cannot grow the stack to that size. This
function never shrinks the stack; if the stack is already larger than
the new size, it is left unchanged.
lua_close *lua_close()*
>c
void lua_close (lua_State *L);
<
Destroys all objects in the given Lua state (calling the corresponding
garbage-collection metamethods, if any) and frees all dynamic memory
used by this state. On several platforms, you may not need to call
this function, because all resources are naturally released when the
host program ends. On the other hand, long-running programs, such as a
daemon or a web server, might need to release states as soon as they
are not needed, to avoid growing too large.
lua_concat *lua_concat()*
>c
void lua_concat (lua_State *L, int n);
<
Concatenates the `n` values at the top of the stack, pops them, and
leaves the result at the top. If `n` is 1, the result is the single
string on the stack (that is, the function does nothing); if `n` is 0,
the result is the empty string. Concatenation is done following the
usual semantics of Lua (see |lua-concat|).
lua_cpcall *lua_cpcall()*
>c
int lua_cpcall (lua_State *L, lua_CFunction func, void *ud);
<
Calls the C function `func` in protected mode. `func` starts with only
one element in its stack, a light userdata containing `ud`. In case of
errors, `lua_cpcall` returns the same error codes as `lua_pcall` (see
|lua_pcall()|), plus the error object on the top of the stack;
otherwise, it returns zero, and does not change the stack. All values
returned by `func` are discarded.
lua_createtable *lua_createtable()*
>c
void lua_createtable (lua_State *L, int narr, int nrec);
<
Creates a new empty table and pushes it onto the stack. The new table
has space pre-allocated for `narr` array elements and `nrec` non-array
elements. This pre-allocation is useful when you know exactly how many
elements the table will have. Otherwise you can use the function
`lua_newtable` (see |lua_newtable()|).
lua_dump *lua_dump()*
>c
int lua_dump (lua_State *L, lua_Writer writer, void *data);
<
Dumps a function as a binary chunk. Receives a Lua function on the top
of the stack and produces a binary chunk that, if loaded again,
results in a function equivalent to the one dumped. As it produces
parts of the chunk, `lua_dump` calls function `writer` (see
|lua_Writer|) with the given `data` to write them.
The value returned is the error code returned by the last call to the
writer; 0 means no errors.
This function does not pop the Lua function from the stack.
lua_equal *lua_equal()*
>c
int lua_equal (lua_State *L, int index1, int index2);
<
Returns 1 if the two values in acceptable indices `index1` and
`index2` are equal, following the semantics of the Lua `==` operator
(that is, may call metamethods). Otherwise returns 0. Also returns 0
if any of the indices is non valid.
lua_error