@@ -1199,34 +1199,34 @@ int output_flex_t::app_define_table()
11991199 setup_id_columns (&new_table);
12001200 setup_flex_table_columns (&new_table);
12011201
1202- // NOLINTNEXTLINE(performance-no-int-to-ptr)
1203- lua_pushlightuserdata (lua_state (), (void *)(m_tables->size ()));
1202+ void *ptr = lua_newuserdata (lua_state (), sizeof (std::size_t ));
1203+ std::size_t *num = new (ptr) std::size_t {};
1204+ *num = m_tables->size () - 1 ;
12041205 luaL_getmetatable (lua_state (), osm2pgsql_table_name);
12051206 lua_setmetatable (lua_state (), -2 );
12061207
12071208 return 1 ;
12081209}
12091210
1210- // Check that the first element on the Lua stack is an osm2pgsql.table
1211+ // Check that the first element on the Lua stack is an osm2pgsql.Table
12111212// parameter and return its internal table index.
12121213static std::size_t table_idx_from_param (lua_State *lua_state)
12131214{
12141215 void const *const user_data = lua_touserdata (lua_state, 1 );
12151216
12161217 if (user_data == nullptr || !lua_getmetatable (lua_state, 1 )) {
12171218 throw std::runtime_error{
1218- " First parameter must be of type osm2pgsql.table ." };
1219+ " First parameter must be of type osm2pgsql.Table ." };
12191220 }
12201221
12211222 luaL_getmetatable (lua_state, osm2pgsql_table_name);
12221223 if (!lua_rawequal (lua_state, -1 , -2 )) {
12231224 throw std::runtime_error{
1224- " First parameter must be of type osm2pgsql.table ." };
1225+ " First parameter must be of type osm2pgsql.Table ." };
12251226 }
12261227 lua_pop (lua_state, 2 );
12271228
1228- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
1229- return reinterpret_cast <uintptr_t >(user_data) - 1 ;
1229+ return *static_cast <std::size_t const *>(user_data);
12301230}
12311231
12321232// Get the flex table that is as first parameter on the Lua stack.
0 commit comments