-rw-r--r-- | libopie2/opiedb/osqlitedriver.cpp | 9 | ||||
-rw-r--r-- | libopie2/opiedb/osqlitedriver.h | 2 |
2 files changed, 5 insertions, 6 deletions
diff --git a/libopie2/opiedb/osqlitedriver.cpp b/libopie2/opiedb/osqlitedriver.cpp index f07d520..3ba161e 100644 --- a/libopie2/opiedb/osqlitedriver.cpp +++ b/libopie2/opiedb/osqlitedriver.cpp @@ -115,65 +115,64 @@ void rlikeFunc(sqlite_func *context, int arg, const char **argv){ } sqlite_set_result_int(context, sqliteRlikeCompare((const char*)argv[0], (const char*)argv[1], (sqregex*)argv[2])); } /* * try to open a db specified via setUrl * and options */ bool OSQLiteDriver::open() { char *error; qDebug("OSQLiteDriver::open: about to open"); m_sqlite = sqlite_open(m_url.local8Bit(), 0, &error ); /* failed to open */ if (m_sqlite == 0l ) { // FIXME set the last error qWarning("OSQLiteDriver::open: %s", error ); free( error ); return false; } - sqreg = (sqregex *)malloc(sizeof(sqreg)); sqlite_create_function(m_sqlite,"rlike",3,rlikeFunc,&sqreg); return true; } /* close the db * sqlite closes them without * telling failure or success */ bool OSQLiteDriver::close() { if (m_sqlite ) sqlite_close( m_sqlite ), m_sqlite=0l; - if (sqreg->regex_raw != NULL){ - free(sqreg->regex_raw); - sqreg->regex_raw=NULL; - regfree(&sqreg->regex_c); + if (sqreg.regex_raw != NULL){ + free(sqreg.regex_raw); + sqreg.regex_raw=NULL; + regfree(&sqreg.regex_c); } return true; } /* Query */ OSQLResult OSQLiteDriver::query( OSQLQuery* qu) { if ( !m_sqlite ) { // FIXME set error code OSQLResult result( OSQLResult::Failure ); return result; } Query query; query.driver = this; char *err; /* SQLITE_OK 0 if return code > 0 == failure */ if ( sqlite_exec(m_sqlite, qu->query(),&call_back, &query, &err) > 0 ) { qWarning("OSQLiteDriver::query: Error while executing"); free(err ); // FixMe Errors } OSQLResult result(OSQLResult::Success, query.items, diff --git a/libopie2/opiedb/osqlitedriver.h b/libopie2/opiedb/osqlitedriver.h index 95c9e2f..adec331 100644 --- a/libopie2/opiedb/osqlitedriver.h +++ b/libopie2/opiedb/osqlitedriver.h @@ -20,31 +20,31 @@ struct sqregex { class OSQLiteDriver : public OSQLDriver { Q_OBJECT public: OSQLiteDriver( QLibrary *lib = 0l ); ~OSQLiteDriver(); QString id()const; void setUserName( const QString& ); void setPassword( const QString& ); void setUrl( const QString& url ); void setOptions( const QStringList& ); bool open(); bool close(); OSQLError lastError(); OSQLResult query( OSQLQuery* ); OSQLTable::ValueList tables()const; private: OSQLError m_lastE; OSQLResult m_result; OSQLResultItem m_items; int handleCallBack( int, char**, char** ); static int call_back( void*, int, char**, char** ); QString m_url; sqlite *m_sqlite; - sqregex *sqreg; + sqregex sqreg; }; } } } #endif |