summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/openssl.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/openssl.c b/src/openssl.c
index 8977234..9dbcda7 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -1181,18 +1181,23 @@ static int ex__gc(lua_State *L) {
1181 return 0; 1181 return 0;
1182} /* ex__gc() */ 1182} /* ex__gc() */
1183 1183
1184static void ex_newstate(lua_State *L) { 1184static _Bool ex_hasstate(lua_State *L) {
1185 struct ex_state *state; 1185 _Bool has;
1186 struct lua_State *thr;
1187 1186
1188 lua_pushlightuserdata(L, (void *)&ex__gc); 1187 lua_pushlightuserdata(L, (void *)&ex__gc);
1189 lua_gettable(L, LUA_REGISTRYINDEX); 1188 lua_gettable(L, LUA_REGISTRYINDEX);
1189 has = !lua_isnil(L, -1);
1190 lua_pop(L, 1);
1190 1191
1191 if (!lua_isnil(L, -1)) { 1192 return has;
1192 lua_pop(L, 1); 1193} /* ex_hasstate() */
1193 1194
1195static void ex_newstate(lua_State *L) {
1196 struct ex_state *state;
1197 struct lua_State *thr;
1198
1199 if (ex_hasstate(L))
1194 return; 1200 return;
1195 }
1196 1201
1197 state = prepudata(L, sizeof *state, NULL, &ex__gc); 1202 state = prepudata(L, sizeof *state, NULL, &ex__gc);
1198 LIST_INIT(&state->data); 1203 LIST_INIT(&state->data);