From 92689e651e59decfc567893c148a3beb546e3d7c Mon Sep 17 00:00:00 2001 From: Thierry Fournier Date: Sat, 28 Nov 2020 11:21:25 +0100 Subject: [PATCH] MINOR: lua-thread: Stop usage of struct hlua for the global lua state The goal is to no longer use "struct hlua" with global main lua_state. The usage of the "struct hlua" is no longer required. This patch replaces this struct by another one. Now, the usage of runtime Lua phase is separated from the start lua phase. --- src/hlua.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/hlua.c b/src/hlua.c index 3d92c7d..f6db9fe 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -157,7 +157,9 @@ static int hlua_panic_ljmp(lua_State *L) { WILL_LJMP(longjmp(safe_ljmp_env, 1)); #define APPLET_RSP_SENT 0x40 /* The response was fully sent */ /* The main Lua execution context. */ -struct hlua gL; +struct { + lua_State *T; +} gL; /* This is the memory pool containing struct lua for applets * (including cli). @@ -8400,12 +8402,7 @@ void hlua_init(void) #endif /* Init main lua stack. */ - gL.Mref = LUA_REFNIL; - gL.flags = 0; - LIST_INIT(&gL.com); gL.T = lua_newstate(hlua_alloc, &hlua_global_allocator); - gL.Tref = LUA_REFNIL; - gL.task = NULL; /* Initialise Lua context to NULL */ context = lua_getextraspace(gL.T); -- 1.7.10.4