get rid of state_size

This commit is contained in:
Kartik K. Agaram 2021-10-24 09:38:51 -07:00
parent a3c090ce09
commit a1d3225305
2 changed files with 5 additions and 6 deletions

View File

@ -24,7 +24,6 @@
#include "ltm.h"
#define state_size(x) (sizeof(x))
#define fromstate(l) (cast(lu_byte *, (l)))
#define tostate(l) (cast(lua_State *, cast(lu_byte *, l)))
@ -112,12 +111,12 @@ static void close_state (lua_State *L) {
luaZ_freebuffer(L, &g->buff);
freestack(L, L);
lua_assert(g->totalbytes == sizeof(LG));
(*g->frealloc)(g->ud, fromstate(L), state_size(LG), 0);
(*g->frealloc)(g->ud, fromstate(L), sizeof(LG), 0);
}
lua_State *luaE_newthread (lua_State *L) {
lua_State *L1 = tostate(luaM_malloc(L, state_size(lua_State)));
lua_State *L1 = tostate(luaM_malloc(L, sizeof(lua_State)));
luaC_link(L, obj2gco(L1), LUA_TTHREAD);
preinit_state(L1, G(L));
stack_init(L1, L); /* init stack */
@ -136,7 +135,7 @@ void luaE_freethread (lua_State *L, lua_State *L1) {
lua_assert(L1->openupval == NULL);
luai_userstatefree(L1);
freestack(L, L1);
luaM_freemem(L, fromstate(L1), state_size(lua_State));
luaM_freemem(L, fromstate(L1), sizeof(lua_State));
}
@ -144,7 +143,7 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
int i;
lua_State *L;
global_State *g;
void *l = (*f)(ud, NULL, 0, state_size(LG));
void *l = (*f)(ud, NULL, 0, sizeof(LG));
if (l == NULL) return NULL;
L = tostate(l);
g = &((LG *)L)->g;

View File

@ -8,7 +8,7 @@ lua_State:
&{Value; int tt} stack, stack_last, base, top
== todo stack
delete statesize/from_state/to_state
delete fromstate/tostate
eradicate LUAI_EXTRASPACE
lua_newstate
lua_State's stack