Skip to content

Commit 1839835

Browse files
committed
Use anonymous namespace instead of static in more places
1 parent 53fd9cc commit 1839835

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

src/gen/osm2pgsql-gen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
// context object.
6161
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
6262
#define TRAMPOLINE(func_name, lua_name) \
63-
static int lua_trampoline_##func_name(lua_State *lua_state) \
63+
int lua_trampoline_##func_name(lua_State *lua_state) \
6464
{ \
6565
try { \
6666
return static_cast<genproc_t *>(luaX_get_context(lua_state)) \

src/lua-utils.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@ void *luaX_get_context(lua_State *lua_state) noexcept
3333

3434
#else
3535

36+
namespace {
37+
3638
// Unique key for lua registry
37-
static char const *osm2pgsql_output_flex = "osm2pgsql_output_flex";
39+
constexpr char const *const osm2pgsql_output_flex = "osm2pgsql_output_flex";
40+
41+
} // anonymous namespace
3842

3943
void luaX_set_context(lua_State *lua_state, void *ptr) noexcept
4044
{

src/output-flex.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,18 @@
4949
#include <string>
5050
#include <string_view>
5151

52+
namespace {
53+
5254
// Mutex used to coordinate access to Lua code
53-
static std::mutex lua_mutex;
55+
std::mutex lua_mutex;
5456

5557
// Lua can't call functions on C++ objects directly. This macro defines simple
5658
// C "trampoline" functions which are called from Lua which get the current
5759
// context (the output_flex_t object) and call the respective function on the
5860
// context object.
5961
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
6062
#define TRAMPOLINE(func_name, lua_name) \
61-
static int lua_trampoline_##func_name(lua_State *lua_state) \
63+
int lua_trampoline_##func_name(lua_State *lua_state) \
6264
{ \
6365
try { \
6466
return static_cast<output_flex_t *>(luaX_get_context(lua_state)) \
@@ -98,6 +100,8 @@ TRAMPOLINE(expire_output_schema, schema)
98100
TRAMPOLINE(expire_output_table, table)
99101
TRAMPOLINE(expire_output_tostring, __tostring)
100102

103+
} // anonymous namespace
104+
101105
prepared_lua_function_t::prepared_lua_function_t(lua_State *lua_state,
102106
calling_context context,
103107
char const *name, int nresults)

src/properties.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
#include <cassert>
1818
#include <cstdlib>
1919

20-
static constexpr char const *const properties_table = "osm2pgsql_properties";
20+
namespace {
21+
22+
constexpr char const *const properties_table = "osm2pgsql_properties";
23+
24+
} // anonymous namespace
2125

2226
properties_t::properties_t(connection_params_t connection_params,
2327
std::string schema)

src/wkb.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,9 @@ geom::geometry_t ewkb_to_geom(std::string_view wkb)
576576
return geom;
577577
}
578578

579-
static constexpr std::array<char, 256> const hex_table = {
579+
namespace {
580+
581+
constexpr std::array<char, 256> const hex_table = {
580582
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
581583
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
582584
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -587,6 +589,8 @@ static constexpr std::array<char, 256> const hex_table = {
587589
0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0,
588590
};
589591

592+
} // anonymous namespace
593+
590594
unsigned char decode_hex_char(char c) noexcept
591595
{
592596
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-constant-array-index)

0 commit comments

Comments
 (0)