anyone with experience with the lua c api: how does the garbage collection of strings passed from lua to c work? how do you ensure the lua gc does not free the string while c is using it?

@nasser afaik lua_pushstring makes a copy of the string and never keeps any C pointers

Follow

@nasser oh sorry you said from Lua to C. I think the pointer you get from luaL_checkstring is valid only while that stack index is unmodified

· · Web · 1 · 0 · 1

@nasser basically if you want to access that string anywhere outside of the C function being called by Lua, make a copy of it.

Sign in to participate in the conversation
coolkids.house

this is where the cool kids live