lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


You could hold a reference to this value in the registry index:
luaL_ref(current_state, LUA_REGISTRYINDEX);
In this way, there will always ne a reference to ut until you manaully remove the entry from the registry, thus the Garbage Collector won't collect it

Holding a reference in the registry will asure that you can access the string again, however, the const char* pointers returned from most Lua API calls will be invalid after the function returns as the manual states in https://www.lua.org/manual/5.4/manual.html#4.1.3.

Regards,
Xmilia