diff --git a/VM/include/lua.h b/VM/include/lua.h index 7f9647c8..d88e7685 100644 --- a/VM/include/lua.h +++ b/VM/include/lua.h @@ -177,7 +177,7 @@ LUA_API int lua_pushthread(lua_State* L); LUA_API void lua_pushlightuserdata(lua_State* L, void* p); LUA_API void* lua_newuserdatatagged(lua_State* L, size_t sz, int tag); -LUA_API void* lua_newuserdatadtor(lua_State* L, size_t sz, void (*dtor)(void*)); +LUA_API void* lua_newuserdatadtor(lua_State* L, size_t sz, void (*dtor)(lua_State*, void*)); /* ** get functions (Lua -> stack) diff --git a/VM/src/lapi.cpp b/VM/src/lapi.cpp index f3be64b8..49721082 100644 --- a/VM/src/lapi.cpp +++ b/VM/src/lapi.cpp @@ -1213,7 +1213,7 @@ void* lua_newuserdatatagged(lua_State* L, size_t sz, int tag) return u->data; } -void* lua_newuserdatadtor(lua_State* L, size_t sz, void (*dtor)(void*)) +void* lua_newuserdatadtor(lua_State* L, size_t sz, void (*dtor)(lua_State*, void*)) { luaC_checkGC(L); luaC_checkthreadsleep(L); diff --git a/VM/src/ludata.cpp b/VM/src/ludata.cpp index 28152689..8e8e48de 100644 --- a/VM/src/ludata.cpp +++ b/VM/src/ludata.cpp @@ -31,10 +31,10 @@ void luaU_freeudata(lua_State* L, Udata* u, lua_Page* page) } else if (u->tag == UTAG_IDTOR) { - void (*dtor)(void*) = nullptr; + void (*dtor)(lua_State*, void*) = nullptr; memcpy(&dtor, &u->data + u->len - sizeof(dtor), sizeof(dtor)); if (dtor) - dtor(u->data); + dtor(L, u->data); } diff --git a/tests/Conformance.test.cpp b/tests/Conformance.test.cpp index 7b4e83ba..e6bf7d64 100644 --- a/tests/Conformance.test.cpp +++ b/tests/Conformance.test.cpp @@ -668,10 +668,10 @@ TEST_CASE("Reference") lua_State* L = globalState.get(); // note, we push two userdata objects but only pin one of them (the first one) - lua_newuserdatadtor(L, 0, [](void*) { + lua_newuserdatadtor(L, 0, [](lua_State*, void*) { dtorhits++; }); - lua_newuserdatadtor(L, 0, [](void*) { + lua_newuserdatadtor(L, 0, [](lua_State*, void*) { dtorhits++; }); @@ -1092,11 +1092,11 @@ TEST_CASE("UserdataApi") CHECK(lua_userdatatag(L, -1) == 42); // user data with inline dtor - void* ud3 = lua_newuserdatadtor(L, 4, [](void* data) { + void* ud3 = lua_newuserdatadtor(L, 4, [](lua_State*, void* data) { dtorhits += *(int*)data; }); - void* ud4 = lua_newuserdatadtor(L, 1, [](void* data) { + void* ud4 = lua_newuserdatadtor(L, 1, [](lua_State*, void* data) { dtorhits += *(char*)data; });