Skip to content

Commit

Permalink
Deallocate pending freed objects earlier if possible, whenever deallo…
Browse files Browse the repository at this point in the history
…cating a Lua wrapper object.
  • Loading branch information
scoder committed May 31, 2024
1 parent 6029ef1 commit 2e36472
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lupa/_lupa.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,7 @@ cdef class _LuaObject:
locked = lock_runtime(runtime, blocking=False)
if locked:
lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, ref)
runtime.clean_up_pending_unrefs() # just in case
unlock_runtime(runtime)
return
runtime.add_pending_unref(ref)
Expand Down Expand Up @@ -1382,6 +1383,7 @@ cdef class _LuaIter:
locked = lock_runtime(runtime, blocking=False)
if locked:
lua.luaL_unref(L, lua.LUA_REGISTRYINDEX, ref)
runtime.clean_up_pending_unrefs() # just in case
unlock_runtime(runtime)
return
runtime.add_pending_unref(ref)
Expand Down

0 comments on commit 2e36472

Please sign in to comment.