From 6a5e41e2f8a983073cdfb8b717bdb566d422fd57 Mon Sep 17 00:00:00 2001 From: kishoramballi Date: Tue, 3 Feb 2009 08:45:16 +0000 Subject: [PATCH] memory leak fixes --- include/Index.h | 2 ++ include/TableImpl.h | 14 +++++++++----- src/storage/TableImpl.cxx | 3 ++- test/tools/catalog/common.h | 1 + test/tools/csqldump/insert.c | 4 ++-- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/include/Index.h b/include/Index.h index 8484b8bb..6229a393 100644 --- a/include/Index.h +++ b/include/Index.h @@ -182,6 +182,7 @@ class IndexInfo { public: IndexType indType; + virtual ~IndexInfo() {} }; //Used by TableImpl to cache information related to hash indexes on that table @@ -200,6 +201,7 @@ class HashIndexInfo :public IndexInfo { printf("HashIndexInfo indexPtr:%x noOfBuckets:%d buckets:%x \n",indexPtr, noOfBuckets, buckets); } + ~HashIndexInfo() { idxFldList.removeAll(); } }; #endif diff --git a/include/TableImpl.h b/include/TableImpl.h index 88a2c694..671ad79d 100644 --- a/include/TableImpl.h +++ b/include/TableImpl.h @@ -57,15 +57,19 @@ class TupleIterator bool isBetween; bool isPointLook; - TupleIterator(){} + TupleIterator() { } public: TupleIterator(Predicate *p, ScanType t, IndexInfo *i, void *cptr, int pslot,bool between , bool isPtLook) - { bIter = NULL; pred_ = p ; scanType_ = t; info = i; chunkPtr_ = cptr; procSlot =pslot; isBetween=between; isPointLook=isPtLook; } + { bIter = NULL; cIter = NULL; tIter = NULL; + pred_ = p ; scanType_ = t; info = i; chunkPtr_ = cptr; + procSlot =pslot; isBetween=between; isPointLook=isPtLook; + } ~TupleIterator() { - if (bIter) delete bIter; - bIter = NULL; + if (bIter) { delete bIter; bIter = NULL; } + if (cIter) { delete cIter; cIter = NULL; } + if (tIter) { delete tIter; tIter = NULL; } } bool isBetInvolved(){ return isBetween;} void setBetInvolved(bool between){ isBetween=between;} @@ -148,7 +152,7 @@ class TableImpl:public Table public: TableImpl() { db_ = NULL; chunkPtr_ = NULL; iter = NULL; idxInfo = NULL; indexPtr_ = NULL; scanType_ = unknownScan; - pred_ = NULL; useIndex_ = -1; numFlds_ = 0; + pred_ = NULL; useIndex_ = -1; numFlds_ = 0; bindListArray_ = NULL; iNullInfo = 0; cNullInfo = NULL; isIntUsedForNULL = true; iNotNullInfo = 0; cNotNullInfo = NULL; curTuple_ = NULL; isPlanCreated = false; undoFlag = true;} diff --git a/src/storage/TableImpl.cxx b/src/storage/TableImpl.cxx index 3cd831fe..79e6029f 100644 --- a/src/storage/TableImpl.cxx +++ b/src/storage/TableImpl.cxx @@ -1108,7 +1108,8 @@ TableImpl::~TableImpl() idxInfo = NULL; } if (numFlds_ > 31 && cNullInfo != NULL) { free(cNullInfo); cNullInfo = NULL; } - + if (bindList_.size()) bindList_.reset(); + if (bindListArray_) { free (bindListArray_); bindListArray_ = NULL; } fldList_.removeAll(); } diff --git a/test/tools/catalog/common.h b/test/tools/catalog/common.h index d8d2745d..f7165e5d 100644 --- a/test/tools/catalog/common.h +++ b/test/tools/catalog/common.h @@ -9,6 +9,7 @@ DbRetVal createIndex(DatabaseManager *dbMgr, char *tblname, char *fldname, char idxInfo->isUnique = true; DbRetVal rv = dbMgr->createIndex(indname, idxInfo); if (rv != OK) { printf("Index creation failed\n"); return rv; } + delete idxInfo; printf("Index created for %s\n", fldname); return OK; } diff --git a/test/tools/csqldump/insert.c b/test/tools/csqldump/insert.c index e704decb..d4f7bda3 100644 --- a/test/tools/csqldump/insert.c +++ b/test/tools/csqldump/insert.c @@ -16,7 +16,7 @@ int main() if (rv != OK) { printf("Table creation failed\n"); conn.close(); return 3; } printf("Table created\n"); -HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); strcpy(idxInfo->tableName, "t1"); idxInfo->list.append("f1"); idxInfo->isUnique = true; @@ -24,7 +24,7 @@ HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); idxInfo->indType = hashIndex; rv = dbMgr->createIndex("indx", idxInfo); if (rv != OK) { printf("Index creation failed\n"); return ErrUnknown; } - + delete idxInfo; Table *table = dbMgr->openTable("t1"); if (table == NULL) { -- 2.11.4.GIT