LUA_TOLSTRING(3) Library Functions Manual LUA_TOLSTRING(3)

lua_tolstringconverts the Lua value to a C string, function indicator [-0, +0, m]

#include <lua.h>

const char *
lua_tolstring(lua_State *L, int index, size_t *len);

() converts the Lua value at the given acceptable index to a C string. If len is not NULL, it also sets *len with the string length. The Lua value must be a string or a number; otherwise, the function returns NULL. If the value is a number, then lua_tolstring() also changes the actual value in the stack to a string. (This change confuses lua_next(3) when lua_tolstring() is applied to keys during a table traversal.)

lua_tolstring() returns a fully aligned pointer to a string inside the Lua state. This string always has a zero ('\0') after its last character (as in C), but can contain other zeros in its body. Because Lua has garbage collection, there is no guarantee that the pointer returned by lua_tolstring() will be valid after the corresponding value is removed from the stack.

lua_next(3)

Roberto Ierusalimschy, Luiz Henrique de Figueiredo, and Waldemar Celes, Lua 5.1 Reference Manual.

The lua_tolstring() manual page is based on Lua Reference Manual 5.1 and was created by Sergey Bronnikov.

July 14, 2022 Debian