some cleanup, add a note about the lines that cause zm to crash
This commit is contained in:
parent
bc525a4e01
commit
b8f455ee7c
|
@ -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 ) );
|
||||
|
|
31
src/zm_db.h
31
src/zm_db.h
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue