Tag: cws_src680_sqlite
User: aklitzing
Date: 2006/08/21 05:53:26

Modified:
   dba/connectivity/source/drivers/sqlite3/sqConnection.cxx
   dba/connectivity/source/drivers/sqlite3/sqDatabaseMetaData.cxx
   dba/connectivity/source/drivers/sqlite3/sqDB.cpp
   dba/connectivity/source/drivers/sqlite3/sqDB.h
   dba/connectivity/source/drivers/sqlite3/sqPreparedStatement.cxx

Log:
 * queryList changed to stl:slist
 * possible segfaults fixed

File Changes:

Directory: /dba/connectivity/source/drivers/sqlite3/
====================================================

File [changed]: sqConnection.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/sqlite3/sqConnection.cxx?r1=1.1.2.3&r2=1.1.2.4
Delta lines:  +6 -5
-------------------
--- sqConnection.cxx    19 Aug 2006 18:23:28 -0000      1.1.2.3
+++ sqConnection.cxx    21 Aug 2006 12:53:23 -0000      1.1.2.4
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: sqConnection.cxx,v $
  *
- *  $Revision: 1.1.2.3 $
+ *  $Revision: 1.1.2.4 $
  *
- *  last change: $Author: aklitzing $ $Date: 2006/08/19 18:23:28 $
+ *  last change: $Author: aklitzing $ $Date: 2006/08/21 12:53:23 $
  *
  *  Original contributor: André Klitzing
  *
@@ -102,8 +102,8 @@
        nLen = url.indexOf(':',nLen+1);
        OUString filename = url.copy(nLen+1);
 
-       //! \todo UTF16 is needed here later
-       if(m_dataBase->openDatabase(::rtl::OUStringToOString(filename, 
RTL_TEXTENCODING_UTF8).getStr()) != SQLITE_OK)
+       ::rtl::OString fileTmp = ::rtl::OUStringToOString(filename, 
RTL_TEXTENCODING_UTF8);
+       if(m_dataBase->openDatabase(fileTmp.getStr()) != SQLITE_OK)
        {
                osl_decrementInterlockedCount( &m_refCount );
        throw SQLException(OUString(RTL_CONSTASCII_USTRINGPARAM("Unable to open 
database")), *this,
@@ -140,7 +140,8 @@
        if(m_aTypeInfo.empty())
                buildTypeInfo();
 
-       sqQueryPreparedCursor* query = 
m_dataBase->getQueryCursor(rtl::OUStringToOString(_sSql, 
RTL_TEXTENCODING_UTF8).getStr());
+       ::rtl::OString _sSqlTmp = ::rtl::OUStringToOString(_sSql, 
RTL_TEXTENCODING_UTF8);
+       sqQueryPreparedCursor* query = 
m_dataBase->getQueryCursor(_sSqlTmp.getStr());
        Reference< XPreparedStatement > xReturn = new OPreparedStatement(this, 
m_aTypeInfo, query);
        m_aStatements.push_back(WeakReferenceHelper(xReturn));
        return xReturn;

File [changed]: sqDatabaseMetaData.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/sqlite3/sqDatabaseMetaData.cxx?r1=1.1.2.8&r2=1.1.2.9
Delta lines:  +9 -6
-------------------
--- sqDatabaseMetaData.cxx      20 Aug 2006 23:34:27 -0000      1.1.2.8
+++ sqDatabaseMetaData.cxx      21 Aug 2006 12:53:23 -0000      1.1.2.9
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: sqDatabaseMetaData.cxx,v $
  *
- *  $Revision: 1.1.2.8 $
+ *  $Revision: 1.1.2.9 $
  *
- *  last change: $Author: aklitzing $ $Date: 2006/08/20 23:34:27 $
+ *  last change: $Author: aklitzing $ $Date: 2006/08/21 12:53:23 $
  *
  *  Original contributor: André Klitzing
  *
@@ -919,7 +919,8 @@
        ODatabaseMetaDataResultSet::ORows rRows;
 
        sqDB* db = m_pConnection->getDB();
-       const char* mTableName = ::rtl::OUStringToOString(tableNamePattern, 
RTL_TEXTENCODING_UTF8).getStr();
+       ::rtl::OString aTemp = ::rtl::OUStringToOString(tableNamePattern, 
RTL_TEXTENCODING_UTF8);
+       const char* mTableName = aTemp.getStr();
 
        if (mTableName != NULL)
        {
@@ -1040,7 +1041,8 @@
 {
        sqDB* db = m_pConnection->getDB();
        ::rtl::OString stmt = ::rtl::OString("SELECT name FROM sqlite_master 
WHERE type = '%q'");
-       sqQueryPrepared* query = db->getQuery(stmt, 
tableType.toAsciiLowerCase().getStr()); // SQLite needs lowercase but OOo needs 
uppercase
+       ::rtl::OString tableTypetmp = tableType.toAsciiLowerCase();
+       sqQueryPrepared* query = db->getQuery(stmt, tableTypetmp.getStr()); // 
SQLite needs lowercase but OOo needs uppercase
        checkError(query, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unable 
to get table/view information")));
 
        for (query->execute(); !query->isDone(); query->nextRow())
@@ -1115,7 +1117,8 @@
        pResultSet->setPrimaryKeysMap();/*
        ODatabaseMetaDataResultSet::ORows rRows;
 
-       const char* tablename = ::rtl::OUStringToOString(table, 
RTL_TEXTENCODING_UTF8).getStr();
+       ::rtl::OString strTmp = ::rtl::OUStringToOString(table, 
RTL_TEXTENCODING_UTF8);
+       const char* tablename = strTmp.getStr();
        sqDB* db = m_pConnection->getDB();
 
        sqQueryPrepared* query = db->getQuery(::rtl::OString("pragma 
table_info(%q)"), tablename);

File [changed]: sqDB.cpp
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/sqlite3/sqDB.cpp?r1=1.1.2.5&r2=1.1.2.6
Delta lines:  +11 -81
---------------------
--- sqDB.cpp    21 Aug 2006 12:01:55 -0000      1.1.2.5
+++ sqDB.cpp    21 Aug 2006 12:53:24 -0000      1.1.2.6
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: sqDB.cpp,v $
  *
- *  $Revision: 1.1.2.5 $
+ *  $Revision: 1.1.2.6 $
  *
- *  last change: $Author: oj $ $Date: 2006/08/21 12:01:55 $
+ *  last change: $Author: aklitzing $ $Date: 2006/08/21 12:53:24 $
  *
  *  Original contributor: André Klitzing
  *
@@ -154,7 +154,7 @@
        sqQueryTable* ret = new sqQueryTable(resultCode, errorMsg, rows, cols, 
result);
 
        setTransactionError(resultCode);
-       m_list.add(ret);
+       m_list.push_front(ret);
 
        return ret;
 
@@ -169,7 +169,7 @@
        sqQueryPreparedCursor* ret = new sqQueryPreparedCursor(resultCode, 
unused_stmt, stmt, this);
 
        setTransactionError(resultCode);
-       m_list.add(ret);
+       m_list.push_front(ret);
 
        return ret;
 }
@@ -204,10 +204,17 @@
 }
 
 
-
 void sqDB::free(const sqQuery* delQuery)
 {
-       m_list.free(delQuery);
+       for(::std::slist<const sqQuery*>::iterator iter = m_list.begin(); iter 
!= m_list.end(); ++iter)
+       {
+               if(delQuery == *iter)
+               {
+                       delete *iter;
+                       m_list.erase(iter);
+                       break;
+               }
+       }
 }
 
 
@@ -238,81 +245,4 @@
 int sqDB::rollback()
 {
        return sendQuery("ROLLBACK");
-}
-
-
-// 
--------------------------------------------------------------------------------------------------------
-// queryList
-// 
--------------------------------------------------------------------------------------------------------
-
-// private
-void sqDB::queryList::deleteNode(node* delNode)
-{
-       delete delNode->query;
-       delete delNode;
-}
-
-
-// public
-sqDB::queryList::queryList() : head(0), tail(0) {};
-
-//! \todo auf Fehler testen!
-void sqDB::queryList::add(const sqQuery* newQuery) // push_back
-{
-       node* tmp = new node;
-       tmp->query = newQuery;
-       tmp->next = 0;
-
-       if(head == 0)
-       {
-               head = tmp;
-               tail = tmp;
-       }
-       else
-       {
-               tail->next = tmp;
-               tail = tmp;
-       }
-}
-
-//! \todo auf Fehler testen!
-void sqDB::queryList::free(const sqQuery* delQuery)
-{
-       if(head != 0)
-       {
-               if(head->query == delQuery)
-               {
-                       node* tmp = head;
-                       head = head->next;
-                       deleteNode(tmp);
-               }
-               else
-               {
-                       node* prev=head;
-                       for(node* cur=head->next; cur != 0; cur = cur->next)
-                       {
-                               if(cur->query == delQuery)
-                               {
-                                       prev->next = cur->next;
-                                       deleteNode(cur);
-                               }
-                               else
-                                       prev=cur;
-                       }
-               }
-       }
-}
-
-sqDB::queryList::~queryList()
-{
-       if(head != 0)
-       {
-               node* prev;
-               for(node* cur = head; cur != 0; )
-               {
-                       prev = cur;
-                       cur = cur->next;
-                       deleteNode(prev);
-               }
-       }
 }

File [changed]: sqDB.h
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/sqlite3/sqDB.h?r1=1.1.2.5&r2=1.1.2.6
Delta lines:  +2 -25
--------------------
--- sqDB.h      21 Aug 2006 12:01:55 -0000      1.1.2.5
+++ sqDB.h      21 Aug 2006 12:53:24 -0000      1.1.2.6
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: sqDB.h,v $
  *
- *  $Revision: 1.1.2.5 $
+ *  $Revision: 1.1.2.6 $
  *
- *  last change: $Author: oj $ $Date: 2006/08/21 12:01:55 $
+ *  last change: $Author: aklitzing $ $Date: 2006/08/21 12:53:24 $
  *
  *  Original contributor: André Klitzing
  *
@@ -41,6 +41,7 @@
 #include <sqlite3.h>
 #include "sqQueryPreparedCursor.h"
 #include "sqQueryTable.h"
+#include <slist>
 // #include "sqQueryPrepared.h" // you don't need it - sqQueryPreparedCursor 
has it
 
 typedef unsigned short utf16;
@@ -86,32 +87,8 @@
 class sqDB
 {
 private:
-               //! queryList keeps ALL querys of the current database 
connection
-               /*!
-                       If an user forget to free() the result table - this 
will avoid memory leaks and problems with non-finalized statements!
-               */
-               class queryList
-               {
-                       private:
-                       struct node
-                       {
-                               const sqQuery* query;
-                               node* next;
-                       };
-                       node* head;
-                       node* tail;
-
-                       void deleteNode(node* delNode);
-
-                       public:
-                       queryList();
-                       ~queryList();
-                       void add(const sqQuery* newQuery);
-                       void free(const sqQuery* delQuery);
-               };
-
        sqlite3*        m_db; //!< pointer to a sqlite3 database file, 
otherwise it is a NULL-Pointer
-       queryList       m_list; //!< the list to hold every sqQuery* that this 
object will return
+       ::std::slist< const sqQuery* > m_list; //!< the list to hold every 
sqQuery* that this object will return
        const char*     m_filename; //!< (path+)filename of used sqlite3 
database file
        bool            m_errorTransaction; //!< flag for an error during 
transaction
 

File [changed]: sqPreparedStatement.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/sqlite3/sqPreparedStatement.cxx?r1=1.1.2.5&r2=1.1.2.6
Delta lines:  +4 -3
-------------------
--- sqPreparedStatement.cxx     20 Aug 2006 23:34:27 -0000      1.1.2.5
+++ sqPreparedStatement.cxx     21 Aug 2006 12:53:24 -0000      1.1.2.6
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: sqPreparedStatement.cxx,v $
  *
- *  $Revision: 1.1.2.5 $
+ *  $Revision: 1.1.2.6 $
  *
- *  last change: $Author: aklitzing $ $Date: 2006/08/20 23:34:27 $
+ *  last change: $Author: aklitzing $ $Date: 2006/08/21 12:53:24 $
  *
  *  Original contributor: André Klitzing
  *
@@ -184,7 +184,8 @@
        ::osl::MutexGuard aGuard( m_aMutex );
        checkDisposed(OStatement_BASE::rBHelper.bDisposed);
 
-       m_pQuery->setTextUTF16(parameterIndex, x.getStr(), 
x.getLength()*sizeof(sal_Unicode)); // just a work-around
+       ::rtl::OString strTmp = ::rtl::OUStringToOString(x, 
RTL_TEXTENCODING_UTF8);
+       m_pQuery->setText(parameterIndex, strTmp.getStr());
 }
 // -------------------------------------------------------------------------
 




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to