[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Odd looking code in lmem.c
- From: Paige DePol <lual@...>
- Date: Thu, 26 Jun 2014 19:15:29 -0500
On Jun 26, 2014, at 5:57 PM, Tom N Harris <firstname.lastname@example.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
> 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.