lua-users home
lua-l archive

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


孙世龙 sunshilong <sunshilong369@gmail.com> 于2020年8月13日周四 上午11:21写道:
>
> Hi, list
>
> 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()?

RTFM : http://www.lua.org/manual/5.4/manual.html#lua_Alloc

When ptr is NULL, osize encodes the kind of object that Lua is
allocating. osize is any of LUA_TSTRING, LUA_TTABLE, LUA_TFUNCTION,
LUA_TUSERDATA, or LUA_TTHREAD when (and only when) Lua is creating a
new object of that type. When osize is some other value, Lua is
allocating memory for something else.