|
@@ -148,10 +148,7 @@ static int l_term_equals (lua_State *L)
|
|
static int l_term_gc (lua_State *L)
|
|
static int l_term_gc (lua_State *L)
|
|
{
|
|
{
|
|
LSUP_Term **tp = luaL_checkudata(L, 1, "LSUP.Term");
|
|
LSUP_Term **tp = luaL_checkudata(L, 1, "LSUP.Term");
|
|
- // FIXME This is to prevent a double-free on shutdown.
|
|
|
|
- // Must find the culprit instead.
|
|
|
|
- if (UNLIKELY (!tp || !*tp)) return 0;
|
|
|
|
- LOG_DEBUG ("Garbage collecting term @%p", *tp);
|
|
|
|
|
|
+ LOG_TRACE ("Garbage collecting term @%p", *tp);
|
|
|
|
|
|
LSUP_term_free (*tp);
|
|
LSUP_term_free (*tp);
|
|
*tp = NULL;
|
|
*tp = NULL;
|
|
@@ -333,8 +330,7 @@ static int term_set_iter_next (lua_State *L)
|
|
*(LSUP_TermSet **)lua_touserdata (L, lua_upvalueindex (1));
|
|
*(LSUP_TermSet **)lua_touserdata (L, lua_upvalueindex (1));
|
|
size_t *ip = lua_touserdata (L, lua_upvalueindex (2));
|
|
size_t *ip = lua_touserdata (L, lua_upvalueindex (2));
|
|
|
|
|
|
- LSUP_Term **tp = allocate_term (L);
|
|
|
|
- LSUP_Term *tmp = NULL;
|
|
|
|
|
|
+ LSUP_Term *tmp;
|
|
LSUP_rc rc = LSUP_term_set_next (ts, ip, &tmp);
|
|
LSUP_rc rc = LSUP_term_set_next (ts, ip, &tmp);
|
|
|
|
|
|
LUA_PCHECK (rc, "Error iterating over term set");
|
|
LUA_PCHECK (rc, "Error iterating over term set");
|
|
@@ -344,6 +340,7 @@ static int term_set_iter_next (lua_State *L)
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ LSUP_Term **tp = allocate_term (L);
|
|
*tp = LSUP_term_copy (tmp);
|
|
*tp = LSUP_term_copy (tmp);
|
|
if (!*tp) {
|
|
if (!*tp) {
|
|
free (ip);
|
|
free (ip);
|
|
@@ -571,8 +568,6 @@ int luaopen_lsup_term (lua_State *L)
|
|
*/
|
|
*/
|
|
// Term set.
|
|
// Term set.
|
|
luaL_newmetatable (L, "LSUP.TermSet");
|
|
luaL_newmetatable (L, "LSUP.TermSet");
|
|
- lua_pushvalue (L, -1);
|
|
|
|
- lua_setfield (L, -2, "__index");
|
|
|
|
lua_pushcfunction (L, term_set_gc);
|
|
lua_pushcfunction (L, term_set_gc);
|
|
lua_setfield (L, -2, "__gc");
|
|
lua_setfield (L, -2, "__gc");
|
|
lua_pushcfunction (L, l_term_set_iter_init);
|
|
lua_pushcfunction (L, l_term_set_iter_init);
|
|
@@ -580,8 +575,6 @@ int luaopen_lsup_term (lua_State *L)
|
|
|
|
|
|
// Link map.
|
|
// Link map.
|
|
luaL_newmetatable (L, "LSUP.LinkMap");
|
|
luaL_newmetatable (L, "LSUP.LinkMap");
|
|
- lua_pushvalue (L, -1);
|
|
|
|
- lua_setfield (L, -2, "__index");
|
|
|
|
lua_pushcfunction (L, link_map_gc);
|
|
lua_pushcfunction (L, link_map_gc);
|
|
lua_setfield (L, -2, "__gc");
|
|
lua_setfield (L, -2, "__gc");
|
|
lua_pushcfunction (L, l_lmap_iter_init);
|
|
lua_pushcfunction (L, l_lmap_iter_init);
|