some cleanup, add a note about the lines that cause zm to crash

This commit is contained in:
Isaac Connor 2017-12-03 11:00:40 -05:00
parent bc525a4e01
commit b8f455ee7c
2 changed files with 15 additions and 23 deletions

View File

@ -25,11 +25,12 @@
MYSQL dbconn;
int zmDbConnected = false;
bool zmDbConnected = false;
void zmDbConnect() {
if ( zmDbConnected )
return;
// If these lines are uncommented, we get memory corruption and crashes
//if ( zmDbConnected )
//return;
if ( !mysql_init( &dbconn ) ) {
Error( "Can't initialise database connection: %s", mysql_error( &dbconn ) );

View File

@ -23,35 +23,26 @@
#include <mysql/mysql.h>
class zmDbRow {
private:
MYSQL_RES *result_set;
MYSQL_ROW row;
public:
zmDbRow() { result_set = NULL; row = NULL; };
MYSQL_RES *fetch( const char *query );
zmDbRow( MYSQL_RES *, MYSQL_ROW *row );
~zmDbRow();
private:
MYSQL_RES *result_set;
MYSQL_ROW row;
public:
zmDbRow() { result_set = NULL; row = NULL; };
MYSQL_RES *fetch( const char *query );
zmDbRow( MYSQL_RES *, MYSQL_ROW *row );
~zmDbRow();
char *operator[](unsigned int index) const {
return row[index];
}
char *operator[](unsigned int index) const {
return row[index];
}
};
#ifdef __cplusplus
extern "C" {
#endif
extern MYSQL dbconn;
extern int zmDbConnected;
void zmDbConnect();
void zmDbClose();
MYSQL_RES * zmDbFetch( const char *query );
zmDbRow *zmDbFetchOne( const char *query );
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif // ZM_DB_H