mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 21:07:59 +03:00
Use unique_ptr to handle lua state lifetime
This commit is contained in:
parent
87d77a6882
commit
f80283422f
5 changed files with 48 additions and 42 deletions
18
components/lua/luastateptr.hpp
Normal file
18
components/lua/luastateptr.hpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#ifndef OPENMW_COMPONENTS_LUA_LUASTATEPTR_H
|
||||
#define OPENMW_COMPONENTS_LUA_LUASTATEPTR_H
|
||||
|
||||
#include <sol/state.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace LuaUtil
|
||||
{
|
||||
struct CloseLuaState
|
||||
{
|
||||
void operator()(lua_State* state) noexcept { lua_close(state); }
|
||||
};
|
||||
|
||||
using LuaStatePtr = std::unique_ptr<lua_State, CloseLuaState>;
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue