refactor(Core): replace NULL with nullptr (#4593)
This commit is contained in:
@@ -34,7 +34,7 @@ bool BasicStatementTask::Execute()
|
||||
if (!result || !result->GetRowCount())
|
||||
{
|
||||
delete result;
|
||||
m_result.set(QueryResult(NULL));
|
||||
m_result.set(QueryResult(nullptr));
|
||||
return false;
|
||||
}
|
||||
result->NextRow();
|
||||
|
||||
@@ -23,7 +23,7 @@ int DatabaseWorker::svc()
|
||||
if (!m_queue)
|
||||
return -1;
|
||||
|
||||
SQLOperation* request = NULL;
|
||||
SQLOperation* request = nullptr;
|
||||
while (1)
|
||||
{
|
||||
request = (SQLOperation*)(m_queue->dequeue());
|
||||
|
||||
@@ -149,7 +149,7 @@ QueryResult DatabaseWorkerPool<T>::Query(const char* sql, T* conn /* = nullptr*/
|
||||
if (!result || !result->GetRowCount())
|
||||
{
|
||||
delete result;
|
||||
return QueryResult(NULL);
|
||||
return QueryResult(nullptr);
|
||||
}
|
||||
|
||||
result->NextRow();
|
||||
@@ -169,7 +169,7 @@ PreparedQueryResult DatabaseWorkerPool<T>::Query(PreparedStatement* stmt)
|
||||
if (!ret || !ret->GetRowCount())
|
||||
{
|
||||
delete ret;
|
||||
return PreparedQueryResult(NULL);
|
||||
return PreparedQueryResult(nullptr);
|
||||
}
|
||||
|
||||
return PreparedQueryResult(ret);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
Field::Field()
|
||||
{
|
||||
data.value = NULL;
|
||||
data.value = nullptr;
|
||||
data.type = MYSQL_TYPE_NULL;
|
||||
data.length = 0;
|
||||
data.raw = false;
|
||||
|
||||
@@ -219,7 +219,7 @@ public:
|
||||
if (IsNumeric())
|
||||
{
|
||||
sLog->outSQLDriver("Error: GetCString() on numeric field. Using type: %s.", FieldTypeToString(data.type));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
return static_cast<char const*>(data.value);
|
||||
@@ -381,7 +381,7 @@ private:
|
||||
case MYSQL_TYPE_NEWDATE:
|
||||
return "NEWDATE";
|
||||
case MYSQL_TYPE_NULL:
|
||||
return "NULL";
|
||||
return "nullptr";
|
||||
case MYSQL_TYPE_SET:
|
||||
return "SET";
|
||||
case MYSQL_TYPE_SHORT:
|
||||
|
||||
@@ -26,9 +26,9 @@
|
||||
MySQLConnection::MySQLConnection(MySQLConnectionInfo& connInfo) :
|
||||
m_reconnecting(false),
|
||||
m_prepareError(false),
|
||||
m_queue(NULL),
|
||||
m_worker(NULL),
|
||||
m_Mysql(NULL),
|
||||
m_queue(nullptr),
|
||||
m_worker(nullptr),
|
||||
m_Mysql(nullptr),
|
||||
m_connectionInfo(connInfo),
|
||||
m_connectionFlags(CONNECTION_SYNCH)
|
||||
{
|
||||
@@ -38,7 +38,7 @@ MySQLConnection::MySQLConnection(ACE_Activation_Queue* queue, MySQLConnectionInf
|
||||
m_reconnecting(false),
|
||||
m_prepareError(false),
|
||||
m_queue(queue),
|
||||
m_Mysql(NULL),
|
||||
m_Mysql(nullptr),
|
||||
m_connectionInfo(connInfo),
|
||||
m_connectionFlags(CONNECTION_ASYNC)
|
||||
{
|
||||
@@ -64,7 +64,7 @@ void MySQLConnection::Close()
|
||||
bool MySQLConnection::Open()
|
||||
{
|
||||
MYSQL* mysqlInit;
|
||||
mysqlInit = mysql_init(NULL);
|
||||
mysqlInit = mysql_init(nullptr);
|
||||
if (!mysqlInit)
|
||||
{
|
||||
sLog->outError("Could not initialize Mysql connection to database `%s`", m_connectionInfo.database.c_str());
|
||||
@@ -313,15 +313,15 @@ bool MySQLConnection::_Query(PreparedStatement* stmt, MYSQL_RES** pResult, uint6
|
||||
ResultSet* MySQLConnection::Query(const char* sql)
|
||||
{
|
||||
if (!sql)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
MYSQL_RES* result = NULL;
|
||||
MYSQL_FIELD* fields = NULL;
|
||||
MYSQL_RES* result = nullptr;
|
||||
MYSQL_FIELD* fields = nullptr;
|
||||
uint64 rowCount = 0;
|
||||
uint32 fieldCount = 0;
|
||||
|
||||
if (!_Query(sql, &result, &fields, &rowCount, &fieldCount))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
return new ResultSet(result, fields, rowCount, fieldCount);
|
||||
}
|
||||
@@ -460,7 +460,7 @@ void MySQLConnection::PrepareStatement(uint32 index, const char* sql, Connection
|
||||
// to save memory that will not be used.
|
||||
if (!(m_connectionFlags & flags))
|
||||
{
|
||||
m_stmts[index] = NULL;
|
||||
m_stmts[index] = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -490,12 +490,12 @@ void MySQLConnection::PrepareStatement(uint32 index, const char* sql, Connection
|
||||
|
||||
PreparedResultSet* MySQLConnection::Query(PreparedStatement* stmt)
|
||||
{
|
||||
MYSQL_RES* result = NULL;
|
||||
MYSQL_RES* result = nullptr;
|
||||
uint64 rowCount = 0;
|
||||
uint32 fieldCount = 0;
|
||||
|
||||
if (!_Query(stmt, &result, &rowCount, &fieldCount))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
if (mysql_more_results(m_Mysql))
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "Log.h"
|
||||
|
||||
PreparedStatement::PreparedStatement(uint32 index) :
|
||||
m_stmt(NULL),
|
||||
m_stmt(nullptr),
|
||||
m_index(index)
|
||||
{
|
||||
}
|
||||
@@ -192,9 +192,9 @@ void PreparedStatement::setNull(const uint8 index)
|
||||
}
|
||||
|
||||
MySQLPreparedStatement::MySQLPreparedStatement(MYSQL_STMT* stmt) :
|
||||
m_stmt(NULL),
|
||||
m_stmt(nullptr),
|
||||
m_Mstmt(stmt),
|
||||
m_bind(NULL)
|
||||
m_bind(nullptr)
|
||||
{
|
||||
/// Initialize variable parameters
|
||||
m_paramCount = mysql_stmt_param_count(stmt);
|
||||
@@ -224,9 +224,9 @@ void MySQLPreparedStatement::ClearParameters()
|
||||
for (uint32 i = 0; i < m_paramCount; ++i)
|
||||
{
|
||||
delete m_bind[i].length;
|
||||
m_bind[i].length = NULL;
|
||||
m_bind[i].length = nullptr;
|
||||
delete[] (char*) m_bind[i].buffer;
|
||||
m_bind[i].buffer = NULL;
|
||||
m_bind[i].buffer = nullptr;
|
||||
m_paramsSet[i] = false;
|
||||
}
|
||||
}
|
||||
@@ -356,11 +356,11 @@ void MySQLPreparedStatement::setNull(const uint8 index)
|
||||
MYSQL_BIND* param = &m_bind[index];
|
||||
param->buffer_type = MYSQL_TYPE_NULL;
|
||||
delete [] static_cast<char*>(param->buffer);
|
||||
param->buffer = NULL;
|
||||
param->buffer = nullptr;
|
||||
param->buffer_length = 0;
|
||||
param->is_null_value = 1;
|
||||
delete param->length;
|
||||
param->length = NULL;
|
||||
param->length = nullptr;
|
||||
}
|
||||
|
||||
void MySQLPreparedStatement::setValue(MYSQL_BIND* param, enum_field_types type, const void* value, uint32 len, bool isUnsigned)
|
||||
@@ -370,7 +370,7 @@ void MySQLPreparedStatement::setValue(MYSQL_BIND* param, enum_field_types type,
|
||||
param->buffer = new char[len];
|
||||
param->buffer_length = 0;
|
||||
param->is_null_value = 0;
|
||||
param->length = NULL; // Only != NULL for strings
|
||||
param->length = nullptr; // Only != nullptr for strings
|
||||
param->is_unsigned = isUnsigned;
|
||||
|
||||
memcpy(param->buffer, value, len);
|
||||
@@ -425,7 +425,7 @@ std::string MySQLPreparedStatement::getQueryString(std::string const& sqlPattern
|
||||
ss << '\'' << m_stmt->statement_data[i].str << '\'';
|
||||
break;
|
||||
case TYPE_NULL:
|
||||
ss << "NULL";
|
||||
ss << "nullptr";
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -464,7 +464,7 @@ bool PreparedStatementTask::Execute()
|
||||
if (!result || !result->GetRowCount())
|
||||
{
|
||||
delete result;
|
||||
m_result.set(PreparedQueryResult(NULL));
|
||||
m_result.set(PreparedQueryResult(nullptr));
|
||||
return false;
|
||||
}
|
||||
m_result.set(PreparedQueryResult(result));
|
||||
|
||||
@@ -23,7 +23,7 @@ bool SQLQueryHolder::SetQuery(size_t index, const char* sql)
|
||||
element.element.query = strdup(sql);
|
||||
|
||||
SQLResultSetUnion result;
|
||||
result.qresult = NULL;
|
||||
result.qresult = nullptr;
|
||||
|
||||
m_queries[index] = SQLResultPair(element, result);
|
||||
return true;
|
||||
@@ -66,7 +66,7 @@ bool SQLQueryHolder::SetPreparedQuery(size_t index, PreparedStatement* stmt)
|
||||
element.element.stmt = stmt;
|
||||
|
||||
SQLResultSetUnion result;
|
||||
result.presult = NULL;
|
||||
result.presult = nullptr;
|
||||
|
||||
m_queries[index] = SQLResultPair(element, result);
|
||||
return true;
|
||||
@@ -79,13 +79,13 @@ QueryResult SQLQueryHolder::GetResult(size_t index)
|
||||
{
|
||||
ResultSet* result = m_queries[index].second.qresult;
|
||||
if (!result || !result->GetRowCount())
|
||||
return QueryResult(NULL);
|
||||
return QueryResult(nullptr);
|
||||
|
||||
result->NextRow();
|
||||
return QueryResult(result);
|
||||
}
|
||||
else
|
||||
return QueryResult(NULL);
|
||||
return QueryResult(nullptr);
|
||||
}
|
||||
|
||||
PreparedQueryResult SQLQueryHolder::GetPreparedResult(size_t index)
|
||||
@@ -95,12 +95,12 @@ PreparedQueryResult SQLQueryHolder::GetPreparedResult(size_t index)
|
||||
{
|
||||
PreparedResultSet* result = m_queries[index].second.presult;
|
||||
if (!result || !result->GetRowCount())
|
||||
return PreparedQueryResult(NULL);
|
||||
return PreparedQueryResult(nullptr);
|
||||
|
||||
return PreparedQueryResult(result);
|
||||
}
|
||||
else
|
||||
return PreparedQueryResult(NULL);
|
||||
return PreparedQueryResult(nullptr);
|
||||
}
|
||||
|
||||
void SQLQueryHolder::SetResult(size_t index, ResultSet* result)
|
||||
@@ -108,7 +108,7 @@ void SQLQueryHolder::SetResult(size_t index, ResultSet* result)
|
||||
if (result && !result->GetRowCount())
|
||||
{
|
||||
delete result;
|
||||
result = NULL;
|
||||
result = nullptr;
|
||||
}
|
||||
|
||||
/// store the result in the holder
|
||||
@@ -121,7 +121,7 @@ void SQLQueryHolder::SetPreparedResult(size_t index, PreparedResultSet* result)
|
||||
if (result && !result->GetRowCount())
|
||||
{
|
||||
delete result;
|
||||
result = NULL;
|
||||
result = nullptr;
|
||||
}
|
||||
|
||||
/// store the result in the holder
|
||||
|
||||
@@ -21,11 +21,11 @@ PreparedResultSet::PreparedResultSet(MYSQL_STMT* stmt, MYSQL_RES* result, uint64
|
||||
m_rowCount(rowCount),
|
||||
m_rowPosition(0),
|
||||
m_fieldCount(fieldCount),
|
||||
m_rBind(NULL),
|
||||
m_rBind(nullptr),
|
||||
m_stmt(stmt),
|
||||
m_res(result),
|
||||
m_isNull(NULL),
|
||||
m_length(NULL)
|
||||
m_isNull(nullptr),
|
||||
m_length(nullptr)
|
||||
{
|
||||
if (!m_res)
|
||||
return;
|
||||
@@ -67,7 +67,7 @@ PreparedResultSet::PreparedResultSet(MYSQL_STMT* stmt, MYSQL_RES* result, uint64
|
||||
m_rBind[i].buffer_length = size;
|
||||
m_rBind[i].length = &m_length[i];
|
||||
m_rBind[i].is_null = &m_isNull[i];
|
||||
m_rBind[i].error = NULL;
|
||||
m_rBind[i].error = nullptr;
|
||||
m_rBind[i].is_unsigned = field->flags & UNSIGNED_FLAG;
|
||||
|
||||
++i;
|
||||
@@ -198,13 +198,13 @@ void ResultSet::CleanUp()
|
||||
if (_currentRow)
|
||||
{
|
||||
delete [] _currentRow;
|
||||
_currentRow = NULL;
|
||||
_currentRow = nullptr;
|
||||
}
|
||||
|
||||
if (_result)
|
||||
{
|
||||
mysql_free_result(_result);
|
||||
_result = NULL;
|
||||
_result = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user