lua-users home
lua-l archive

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


On Jun 26, 2014, at 5:57 PM, Tom N Harris <telliamed@whoopdedo.org> wrote:

> On Thursday, June 26, 2014 01:16:57 AM Paige DePol wrote:
>> In vanilla Lua, it does not appear so, you would have to modify the
>> `luaM_realloc_` function to add such functionality yourself. I also run the
>> GC in steps for my game engine so this is something I need to consider as
>> well.
> 
> I was going to say something about a user-defined allocator, but the custom 
> function doesn't have access to the Lua state, does it? That's too bad. I 
> guess you could make the allocator userdata be a lua_State** and copy the 
> state pointer into it after it's created. The pointer would be invalid when 
> creating the state itself, of course.

I had not thought about using a custom allocator, good point, thank you! :)

When creating the state itself the userdata pointer could be NULL, given that if the state is just being created there won't be anything to emergency garbage collect anyway.

~pmd