From baa0e234564a5ceca4211486d1cc70be55a070a2 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 24 Jul 2014 11:00:16 -0300 Subject: better support for extra user space associated with a Lua state --- lstate.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lstate.c') diff --git a/lstate.c b/lstate.c index 607af60a..d4b9f4f0 100644 --- a/lstate.c +++ b/lstate.c @@ -1,5 +1,5 @@ /* -** $Id: lstate.c,v 2.122 2014/07/18 12:17:54 roberto Exp roberto $ +** $Id: lstate.c,v 2.123 2014/07/18 13:36:14 roberto Exp roberto $ ** Global State ** See Copyright Notice in lua.h */ @@ -53,9 +53,7 @@ ** thread state + extra space */ typedef struct LX { -#if defined(LUAI_EXTRASPACE) - char buff[LUAI_EXTRASPACE]; -#endif + lu_byte extra_[LUA_EXTRASPACE]; lua_State l; } LX; @@ -263,6 +261,7 @@ LUA_API lua_State *lua_newthread (lua_State *L) { /* link it on list 'allgc' */ L1->next = g->allgc; g->allgc = obj2gco(L1); + /* anchor it on L stack */ setthvalue(L, L->top, L1); api_incr_top(L); preinit_thread(L1, g); @@ -270,6 +269,8 @@ LUA_API lua_State *lua_newthread (lua_State *L) { L1->basehookcount = L->basehookcount; L1->hook = L->hook; resethookcount(L1); + /* initialize L1 extra space */ + memcpy(lua_getextraspace(L1), lua_getextraspace(L), LUA_EXTRASPACE); luai_userstatethread(L, L1); stack_init(L1, L); /* init stack */ lua_unlock(L); -- cgit v1.2.3-55-g6feb