[8736] operator new[] based version of strdup() function to get bonuses from Intel Memory allocator mainly in DB code

Signed-off-by: Ambal <pogrebniak@gala.net>
This commit is contained in:
Ambal 2009-10-26 01:05:08 +02:00
parent a2ed351365
commit b0ea8848a5
7 changed files with 29 additions and 19 deletions

View file

@ -41,17 +41,17 @@ void SqlTransaction::Execute(Database *db)
if(!db->DirectExecute(sql))
{
free((void*)const_cast<char*>(sql));
delete [] ((void*)const_cast<char*>(sql));
db->DirectExecute("ROLLBACK");
while(!m_queue.empty())
{
free((void*)const_cast<char*>(m_queue.front()));
delete [] ((void*)const_cast<char*>(m_queue.front()));
m_queue.pop();
}
return;
}
free((void*)const_cast<char*>(sql));
delete [] ((void*)const_cast<char*>(sql));
}
db->DirectExecute("COMMIT");
}
@ -107,7 +107,7 @@ bool SqlQueryHolder::SetQuery(size_t index, const char *sql)
}
/// not executed yet, just stored (it's not called a holder for nothing)
m_queries[index] = SqlResultPair(strdup(sql), (QueryResult*)NULL);
m_queries[index] = SqlResultPair(mangos_strdup(sql), (QueryResult*)NULL);
return true;
}
@ -141,7 +141,7 @@ QueryResult* SqlQueryHolder::GetResult(size_t index)
/// the query strings are freed on the first GetResult or in the destructor
if(m_queries[index].first != NULL)
{
free((void*)(const_cast<char*>(m_queries[index].first)));
delete [] ((void*)(const_cast<char*>(m_queries[index].first)));
m_queries[index].first = NULL;
}
/// when you get a result aways remember to delete it!
@ -166,7 +166,7 @@ SqlQueryHolder::~SqlQueryHolder()
/// results used already (getresult called) are expected to be deleted
if(m_queries[i].first != NULL)
{
free((void*)(const_cast<char*>(m_queries[i].first)));
delete [] ((void*)(const_cast<char*>(m_queries[i].first)));
if(m_queries[i].second)
delete m_queries[i].second;
}