Comment by shakna
2 months ago
Lua lets you set the allocator, so you don't have to manage the lifetime.
void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
2 months ago
Lua lets you set the allocator, so you don't have to manage the lifetime.
void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
Two problems with that.
First, it would mean that all Lua objects would be allocated in memory that's potentially executable. That might not necessarily be more of a security issue than the app inherently allows, but at least it's wasteful.
Second, I'm not entirely sure it's a good idea to have C callbacks be collectable, which is why currently they aren't, and you have to free them manually via my winapi.freecallback function. This is part of the inherent issue in the fact that the Windows API has its own concept of lifetimes that are different than Lua's collection visibility. I would like to try to tie them together if possible one day, I'm just not entirely sure how yet.