diff options
Diffstat (limited to 'src/universe.h')
-rw-r--r-- | src/universe.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/universe.h b/src/universe.h index f4211af..113ed21 100644 --- a/src/universe.h +++ b/src/universe.h | |||
@@ -35,7 +35,7 @@ class AllocatorDefinition | |||
35 | lua_Alloc m_allocF{ nullptr }; | 35 | lua_Alloc m_allocF{ nullptr }; |
36 | void* m_allocUD{ nullptr }; | 36 | void* m_allocUD{ nullptr }; |
37 | 37 | ||
38 | static void* operator new(size_t size_, lua_State* L) noexcept { return lua_newuserdatauv(L, size_, 0); } | 38 | [[nodiscard]] static void* operator new(size_t size_, lua_State* L) noexcept { return lua_newuserdatauv(L, size_, 0); } |
39 | // always embedded somewhere else or "in-place constructed" as a full userdata | 39 | // always embedded somewhere else or "in-place constructed" as a full userdata |
40 | // can't actually delete the operator because the compiler generates stack unwinding code that could call it in case of exception | 40 | // can't actually delete the operator because the compiler generates stack unwinding code that could call it in case of exception |
41 | static void operator delete([[maybe_unused]] void* p_, lua_State* L) { ASSERT_L(!"should never be called") }; | 41 | static void operator delete([[maybe_unused]] void* p_, lua_State* L) { ASSERT_L(!"should never be called") }; |
@@ -81,7 +81,7 @@ class ProtectedAllocator : public AllocatorDefinition | |||
81 | 81 | ||
82 | std::mutex m_lock; | 82 | std::mutex m_lock; |
83 | 83 | ||
84 | static void* protected_lua_Alloc(void* ud_, void* ptr_, size_t osize_, size_t nsize_) | 84 | [[nodiscard]] static void* protected_lua_Alloc(void* ud_, void* ptr_, size_t osize_, size_t nsize_) |
85 | { | 85 | { |
86 | ProtectedAllocator* const allocator{ static_cast<ProtectedAllocator*>(ud_) }; | 86 | ProtectedAllocator* const allocator{ static_cast<ProtectedAllocator*>(ud_) }; |
87 | std::lock_guard<std::mutex> guard{ allocator->m_lock }; | 87 | std::lock_guard<std::mutex> guard{ allocator->m_lock }; |
@@ -91,7 +91,7 @@ class ProtectedAllocator : public AllocatorDefinition | |||
91 | public: | 91 | public: |
92 | 92 | ||
93 | // we are not like our base class: we can't be created inside a full userdata (or we would have to install a metatable and __gc handler to destroy ourselves properly) | 93 | // we are not like our base class: we can't be created inside a full userdata (or we would have to install a metatable and __gc handler to destroy ourselves properly) |
94 | static void* operator new(size_t size_, lua_State* L) noexcept = delete; | 94 | [[nodiscard]] static void* operator new(size_t size_, lua_State* L) noexcept = delete; |
95 | static void operator delete(void* p_, lua_State* L) = delete; | 95 | static void operator delete(void* p_, lua_State* L) = delete; |
96 | 96 | ||
97 | AllocatorDefinition makeDefinition() | 97 | AllocatorDefinition makeDefinition() |
@@ -185,6 +185,6 @@ class Universe | |||
185 | 185 | ||
186 | // ################################################################################################ | 186 | // ################################################################################################ |
187 | 187 | ||
188 | Universe* universe_get(lua_State* L); | 188 | [[nodiscard]] Universe* universe_get(lua_State* L); |
189 | Universe* universe_create(lua_State* L); | 189 | [[nodiscard]] Universe* universe_create(lua_State* L); |
190 | void universe_store(lua_State* L, Universe* U); | 190 | void universe_store(lua_State* L, Universe* U); |