[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Since the input argument named osize has not been used in the l_alloc() function, why still pass LUA_TTHREAD to this function in lua_newstate()?
- From: v <v19930312@...>
- Date: Thu, 13 Aug 2020 07:13:47 +0300
On Thu, 2020-08-13 at 11:44 +0800, 孙世龙 sunshilong wrote:
> I see.
> Osize has not been used in the l_alloc() function.
> So I think it's no meaning to pass such arguments(i.e. LUA_TSTRING,
> LUA_TTABLE, LUA_TFUNCTION) to it.
> Am I missing something?
I suppose it is done for user-defined allocators so those can behave
differently for different object types for whatever reason.
Imagine implementation that somehow optimizes allocations for specific
data type, e.g. by using few memory pools with different block sizes,
or even in different type of memory: tiny and fast memory embedded into
microcontroller vs bigger but slower one connected to it externally.
Just because this is not used in default allocator implementation
doesn't mean there are no uses for it in user-defined ones.