Avoid any code before locks in the API
For consistency in the C API, avoid any initializations before callling lua_lock.
This commit is contained in:
5
lstate.c
5
lstate.c
@@ -318,9 +318,10 @@ static void close_state (lua_State *L) {
|
||||
|
||||
|
||||
LUA_API lua_State *lua_newthread (lua_State *L) {
|
||||
global_State *g = G(L);
|
||||
global_State *g;
|
||||
lua_State *L1;
|
||||
lua_lock(L);
|
||||
g = G(L);
|
||||
luaC_checkGC(L);
|
||||
/* create new thread */
|
||||
L1 = &cast(LX *, luaM_newobject(L, LUA_TTHREAD, sizeof(LX)))->l;
|
||||
@@ -437,8 +438,8 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
|
||||
|
||||
|
||||
LUA_API void lua_close (lua_State *L) {
|
||||
L = G(L)->mainthread; /* only the main thread can be closed */
|
||||
lua_lock(L);
|
||||
L = G(L)->mainthread; /* only the main thread can be closed */
|
||||
close_state(L);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user