lua-users home
lua-l archive

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()?

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


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()?
For your convenience, the related code snippets are seen at the footnotes.
Thank you for your attention to this matter.
Here are the related code snippets:
static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
 (void)ud; (void)osize; /* not used */
 if (nsize == 0) {
 free(ptr);
 return NULL;
 }
 else
 return realloc(ptr, nsize);
}
LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
 int i;
 lua_State *L;
 global_State *g;
 LG *l = cast(LG *, (*f)(ud, NULL, LUA_TTHREAD, sizeof(LG)));
 if (l == NULL) return NULL;
...
}
Best Regards.
Sunshilong

AltStyle によって変換されたページ (->オリジナル) /