From 14eba4be4cccf8d98db69d966fed9810b6366682 Mon Sep 17 00:00:00 2001 From: kishoramballi Date: Fri, 6 Feb 2009 09:08:34 +0000 Subject: [PATCH] plugged the leaks --- src/odbc/odbcDbc.h | 2 +- src/odbc/odbcStmt.cxx | 8 ++++++++ src/storage/Condition.cxx | 1 - test/performance/DMLThreadTest.c | 6 +++--- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/odbc/odbcDbc.h b/src/odbc/odbcDbc.h index d9b18366..73e64f0f 100644 --- a/src/odbc/odbcDbc.h +++ b/src/odbc/odbcDbc.h @@ -33,7 +33,7 @@ class CSqlOdbcDbc int mode_; //1->csql , 2->gateway SQLUINTEGER curAccessMode_; IsolationLevel curIsolationLevel_; - + List stmtHdlList_; // Connection Attributes SQLUINTEGER accessMode_; // Transaction access mode // SQL_MODE_READ_ONLY OR diff --git a/src/odbc/odbcStmt.cxx b/src/odbc/odbcStmt.cxx index 794326ad..9d5f8095 100644 --- a/src/odbc/odbcStmt.cxx +++ b/src/odbc/odbcStmt.cxx @@ -60,6 +60,7 @@ SQLRETURN CSqlOdbcStmt::SQLAllocHandle( // Initialize relation b/w Stmt and Dbc inputDbc->stmtList_.insert( inputDbc->stmtList_.begin(), (CSqlOdbcStmt*) *outputHandle ); + inputDbc->stmtHdlList_.append(outputHandle); if( inputDbc->state_ <= C4 ) inputDbc->state_ = C5; ((CSqlOdbcStmt*) *outputHandle)->parentDbc_ = inputDbc; @@ -102,6 +103,13 @@ SQLRETURN CSqlOdbcStmt::SQLFreeHandle( inputStmt->parentDbc_->state_ = C4; inputStmt->handleType_ = -1; // Make object invalid. + SQLHANDLE *elem; + ListIterator it = inputStmt->parentDbc_->stmtHdlList_.getIterator(); + while (it.hasElement()) { + elem = (SQLHANDLE *) it.nextElement(); + if(*elem == inputStmt) *elem = NULL; + } + inputStmt->parentDbc_->stmtHdlList_.remove(elem); delete inputStmt; // Delete Stmt. return( SQL_SUCCESS ); } diff --git a/src/storage/Condition.cxx b/src/storage/Condition.cxx index 0829db0e..a2a304ad 100644 --- a/src/storage/Condition.cxx +++ b/src/storage/Condition.cxx @@ -18,7 +18,6 @@ #include Condition::Condition() { - //pred = new PredicateImpl(); pred = NULL; } void Condition::reset() diff --git a/test/performance/DMLThreadTest.c b/test/performance/DMLThreadTest.c index 61e0a454..6d98b1c7 100644 --- a/test/performance/DMLThreadTest.c +++ b/test/performance/DMLThreadTest.c @@ -26,7 +26,7 @@ int main() idxInfo->indType = hashIndex; rv = dbMgr->createIndex("indx1", idxInfo); if (rv != OK) { printf("Index creation failed\n"); return -1; } - + delete idxInfo; pthread_t thr[THREADS]; int message[THREADS]; int status; @@ -86,7 +86,7 @@ int main() pthread_join(thr[i], (void**)&status); } - //dbMgr->dropTable("t1"); + dbMgr->dropTable("t1"); conn.close(); return 0; } @@ -104,7 +104,7 @@ void* runInsTest(void *message) Table *table = dbMgr->openTable("t1"); if (table == NULL) { printf("Unable to open table\n"); return NULL; } int id = 0; - char name[1020] = "PRABAKARAN"; + char name[200] = "PRABAKARAN"; table->bindFld("f1", &id); table->bindFld("f2", name); char *tuple; -- 2.11.4.GIT