Skip to content

Commit

Permalink
Add optional uservalues count to custom Lua new operator
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Feb 21, 2021
1 parent 9e4a7b5 commit 4f6b0c2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/scripting/lua_common.cpp
Expand Up @@ -496,12 +496,12 @@ std::string register_vconfig_metatable(lua_State *L)

} // end namespace lua_common

void* operator new(std::size_t sz, lua_State *L)
void* operator new(std::size_t sz, lua_State *L, int nuv)
{
return lua_newuserdatauv(L, sz, 0);
return lua_newuserdatauv(L, sz, nuv);
}

void operator delete(void*, lua_State *L)
void operator delete(void*, lua_State *L, int nuv)
{
// Not sure if this is needed since it's a no-op
// It's only called if a constructor throws while using the above operator new
Expand Down
4 changes: 2 additions & 2 deletions src/scripting/lua_common.hpp
Expand Up @@ -41,8 +41,8 @@ namespace lua_common {

}

void* operator new(std::size_t sz, lua_State *L);
void operator delete(void* p, lua_State *L);
void* operator new(std::size_t sz, lua_State *L, int nuv = 0);
void operator delete(void* p, lua_State *L, int nuv);

/**
* Like luaL_getmetafield, but returns false if key is an empty string
Expand Down

0 comments on commit 4f6b0c2

Please sign in to comment.