Explanation about char* parameters in the C API

This commit is contained in:
Roberto I
2026-01-23 16:25:18 -03:00
parent 3360710bd3
commit cfcaa9493b

View File

@@ -2692,7 +2692,19 @@ which behaves like a nil value.
@sect3{constchar|@title{Pointers to Strings}
Several functions in the API return pointers (@T{const char*})
Several functions in the API accept pointers (@T{const char*})
to C strings.
Some of there parameters have an associated length (@T{size_t}).
Unless stated otherwise,
when there is an associated length,
the string can contain embedded zeros;
moreover, the pointer can be @id{NULL} if the length is zero.
When there is no associated length,
the pointer must point to a zero-terminated string.
In any case, the string contents should remain unchanged
until the function returns.
Several functions in the API also return pointers (@T{const char*})
to Lua strings in the stack.
(See @Lid{lua_pushfstring}, @Lid{lua_pushlstring},
@Lid{lua_pushstring}, and @Lid{lua_tolstring}.