about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/lstate.c12
-rw-r--r--src/notes1
2 files changed, 4 insertions, 9 deletions
diff --git a/src/lstate.c b/src/lstate.c
index 26d76d9..cdcd669 100644
--- a/src/lstate.c
+++ b/src/lstate.c
@@ -24,10 +24,6 @@
 #include "ltm.h"
 
 
-#define fromstate(l)	(cast(lu_byte *, (l)))
-#define tostate(l)   (cast(lua_State *, cast(lu_byte *, l)))
-
-
 /*
 ** Main thread combines a thread state and the global state
 */
@@ -111,12 +107,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), sizeof(LG), 0);
+  (*g->frealloc)(g->ud, cast(lu_byte*, L), sizeof(LG), 0);
 }
 
 
 lua_State *luaE_newthread (lua_State *L) {
-  lua_State *L1 = tostate(luaM_malloc(L, sizeof(lua_State)));
+  lua_State *L1 = cast(lua_State*, luaM_malloc(L, sizeof(lua_State)));
   luaC_link(L, obj2gco(L1), LUA_TTHREAD);
   preinit_state(L1, G(L));
   stack_init(L1, L);  /* init stack */
@@ -135,7 +131,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), sizeof(lua_State));
+  luaM_freemem(L, cast(lu_byte*, L1), sizeof(lua_State));
 }
 
 
@@ -145,7 +141,7 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
   global_State *g;
   void *l = (*f)(ud, NULL, 0, sizeof(LG));
   if (l == NULL) return NULL;
-  L = tostate(l);
+  L = cast(lua_State*, l);
   g = &((LG *)L)->g;
   L->next = NULL;
   L->tt = LUA_TTHREAD;
diff --git a/src/notes b/src/notes
index e13492c..3977255 100644
--- a/src/notes
+++ b/src/notes
@@ -8,7 +8,6 @@ lua_State:
   &{Value; int tt} stack, stack_last, base, top
 
 == todo stack
-delete fromstate/tostate
 eradicate LUAI_EXTRASPACE
 lua_newstate
 lua_State's stack