[8744] Fix 'warning: deleting ‘void*’ is undefined' in SqlOperations.h/SqlOperations.cpp, caused by [8736]. Thanks to Shendor for pointing the problem.

Signed-off-by: Ambal <pogrebniak@gala.net>
This commit is contained in:
Ambal 2009-10-27 11:41:53 +02:00
parent a4e3b3e6aa
commit 190c5e6338
4 changed files with 10 additions and 13 deletions

View file

@ -187,10 +187,7 @@ LocaleConstant GetLocaleByName(const std::string& name);
//operator new[] based version of strdup() function! Release memory by using operator delete[] !
inline char * mangos_strdup(const char * source)
{
const size_t length = strlen(source);
char * dest = new char[length + 1];
//set terminating end-of-string symbol
dest[length] = 0;
char * dest = new char[strlen(source) + 1];
strcpy(dest, source);
return dest;
}

View file

@ -36,22 +36,22 @@ void SqlTransaction::Execute(Database *db)
db->DirectExecute("START TRANSACTION");
while(!m_queue.empty())
{
char const *sql = m_queue.front();
char *sql = const_cast<char*>(m_queue.front());
m_queue.pop();
if(!db->DirectExecute(sql))
{
delete [] ((void*)const_cast<char*>(sql));
delete [] sql;
db->DirectExecute("ROLLBACK");
while(!m_queue.empty())
{
delete [] ((void*)const_cast<char*>(m_queue.front()));
delete [] (const_cast<char*>(m_queue.front()));
m_queue.pop();
}
return;
}
delete [] ((void*)const_cast<char*>(sql));
delete [] sql;
}
db->DirectExecute("COMMIT");
}
@ -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)
{
delete [] ((void*)(const_cast<char*>(m_queries[index].first)));
delete [] (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)
{
delete [] ((void*)(const_cast<char*>(m_queries[i].first)));
delete [] (const_cast<char*>(m_queries[i].first));
if(m_queries[i].second)
delete m_queries[i].second;
}

View file

@ -47,7 +47,7 @@ class SqlStatement : public SqlOperation
const char *m_sql;
public:
SqlStatement(const char *sql) : m_sql(mangos_strdup(sql)){}
~SqlStatement() { void* tofree = const_cast<char*>(m_sql); delete [] tofree; }
~SqlStatement() { char* tofree = const_cast<char*>(m_sql); delete [] tofree; }
void Execute(Database *db);
};
@ -85,7 +85,7 @@ class SqlQuery : public SqlOperation
public:
SqlQuery(const char *sql, MaNGOS::IQueryCallback * callback, SqlResultQueue * queue)
: m_sql(mangos_strdup(sql)), m_callback(callback), m_queue(queue) {}
~SqlQuery() { void* tofree = const_cast<char*>(m_sql); delete [] tofree; }
~SqlQuery() { char* tofree = const_cast<char*>(m_sql); delete [] tofree; }
void Execute(Database *db);
};

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "8743"
#define REVISION_NR "8744"
#endif // __REVISION_NR_H__