diff --git a/include/PgSQL_Connection.h b/include/PgSQL_Connection.h index 7722e9454..2e424a05d 100644 --- a/include/PgSQL_Connection.h +++ b/include/PgSQL_Connection.h @@ -216,7 +216,7 @@ private: class PgSQL_Variable { public: - char *value = (char*)""; + char *value = nullptr; void fill_server_internal_session(nlohmann::json &j, int conn_num, int idx); void fill_client_internal_session(nlohmann::json &j, int idx); }; @@ -244,7 +244,7 @@ class PgSQL_Connection_userinfo { class PgSQL_Connection { public: - PgSQL_Connection(bool is_client_conn); + explicit PgSQL_Connection(bool is_client_conn); ~PgSQL_Connection(); PG_ASYNC_ST handler(short event); @@ -500,15 +500,15 @@ public: unsigned long long pgconnpoll_put; } statuses; - PgSQL_Variable variables[PGSQL_NAME_LAST_HIGH_WM]; - uint32_t var_hash[PGSQL_NAME_LAST_HIGH_WM]; + std::array variables = {}; + std::array var_hash = {}; // for now we store possibly missing variables in the lower range // we may need to fix that, but this will cost performance - bool var_absent[PGSQL_NAME_LAST_HIGH_WM] = { false }; + std::array var_absent = {}; std::vector dynamic_variables_idx; - uint32_t startup_parameters_hash[PGSQL_NAME_LAST_HIGH_WM] = {}; - char* startup_parameters[PGSQL_NAME_LAST_HIGH_WM] = {}; + std::array startup_parameters_hash = {}; + std::array startup_parameters = {}; /** * @brief Keeps tracks of the 'server_status'. Do not confuse with the 'server_status' from the diff --git a/lib/PgSQL_Connection.cpp b/lib/PgSQL_Connection.cpp index c1ef2085d..9074d2c04 100644 --- a/lib/PgSQL_Connection.cpp +++ b/lib/PgSQL_Connection.cpp @@ -180,10 +180,10 @@ PgSQL_Connection::PgSQL_Connection(bool is_client_conn) { options.init_connect_sent = false; userinfo = new PgSQL_Connection_userinfo(); - for (int i = 0; i < PGSQL_NAME_LAST_HIGH_WM; i++) { - variables[i].value = NULL; - var_hash[i] = 0; - } + //for (int i = 0; i < PGSQL_NAME_LAST_HIGH_WM; i++) { + // variables[i].value = NULL; + // var_hash[i] = 0; + //} new_result = true; is_copy_out = false; @@ -239,6 +239,7 @@ PgSQL_Connection::~PgSQL_Connection() { for (int i = 0; i < PGSQL_NAME_LAST_HIGH_WM; ++i) { if (startup_parameters[i]) { free(startup_parameters[i]); + startup_parameters[i] = nullptr; startup_parameters_hash[i] = 0; } }