[Winmerge-svn] SF.net SVN: winmerge:[7488] branches/R2_14/Src
Windows visual diff and merge for files and directories
Brought to you by:
christianlist,
grimmdp
From: <ge...@us...> - 2010-12-30 17:02:59
|
Revision: 7488 http://winmerge.svn.sourceforge.net/winmerge/?rev=7488&view=rev Author: gerundt Date: 2010-12-30 17:02:52 +0000 (Thu, 30 Dec 2010) Log Message: ----------- Code cleanup. Don't return reference to pointer but the pointer itself. cppcheck also gave a memory leak error from this code: [DiffItemList.cpp:39]: Memory leak: p Modified Paths: -------------- branches/R2_14/Src/DiffItemList.cpp branches/R2_14/Src/DiffItemList.h branches/R2_14/Src/DirScan.cpp Modified: branches/R2_14/Src/DiffItemList.cpp =================================================================== --- branches/R2_14/Src/DiffItemList.cpp 2010-12-30 16:52:47 UTC (rev 7487) +++ branches/R2_14/Src/DiffItemList.cpp 2010-12-30 17:02:52 UTC (rev 7488) @@ -26,9 +26,11 @@ } /** - * @brief Add new diffitem to structured DIFFITEM tree + * @brief Add new diffitem to structured DIFFITEM tree. + * @param [in] parent Parent item, or NULL if no parent. + * @return Pointer to the added item. */ -DIFFITEM &DiffItemList::AddDiff(DIFFITEM *parent) +DIFFITEM* DiffItemList::AddDiff(DIFFITEM *parent) { DIFFITEM *p = new DIFFITEM; if (parent) @@ -36,7 +38,7 @@ else m_root.Append(p); p->parent = parent; - return *p; + return p; } /** Modified: branches/R2_14/Src/DiffItemList.h =================================================================== --- branches/R2_14/Src/DiffItemList.h 2010-12-30 16:52:47 UTC (rev 7487) +++ branches/R2_14/Src/DiffItemList.h 2010-12-30 17:02:52 UTC (rev 7488) @@ -24,7 +24,7 @@ DiffItemList(); ~DiffItemList(); // add & remove differences - DIFFITEM &AddDiff(DIFFITEM *parent); + DIFFITEM *AddDiff(DIFFITEM *parent); void RemoveDiff(UINT_PTR diffpos); void RemoveAll(); Modified: branches/R2_14/Src/DirScan.cpp =================================================================== --- branches/R2_14/Src/DirScan.cpp 2010-12-30 16:52:47 UTC (rev 7487) +++ branches/R2_14/Src/DirScan.cpp 2010-12-30 17:02:52 UTC (rev 7488) @@ -587,54 +587,54 @@ // We must store both paths - we cannot get paths later // and we need unique item paths for example when items // change to identical - DIFFITEM &di = myStruct->context->AddDiff(parent); + DIFFITEM *di = myStruct->context->AddDiff(parent); if (!sLeftDir.empty()) - di.left.path = sLeftDir; + di->left.path = sLeftDir; if (!sRightDir.empty()) - di.right.path = sRightDir; + di->right.path = sRightDir; if (lent) { - di.left.filename = lent->filename; - di.left.mtime = lent->mtime; - di.left.ctime = lent->ctime; - di.left.size = lent->size; - di.left.flags.attributes = lent->flags.attributes; + di->left.filename = lent->filename; + di->left.mtime = lent->mtime; + di->left.ctime = lent->ctime; + di->left.size = lent->size; + di->left.flags.attributes = lent->flags.attributes; } else { // Don't break CDirView::DoCopyRightToLeft() - di.left.filename = rent->filename; + di->left.filename = rent->filename; } if (rent) { - di.right.filename = OPTIMIZE_SHARE_CSTRINGDATA + di->right.filename = OPTIMIZE_SHARE_CSTRINGDATA ( - di.left.filename.c_str() == rent->filename.c_str() ? di.left.filename : + di->left.filename.c_str() == rent->filename.c_str() ? di->left.filename : ) rent->filename; - di.right.mtime = rent->mtime; - di.right.ctime = rent->ctime; - di.right.size = rent->size; - di.right.flags.attributes = rent->flags.attributes; + di->right.mtime = rent->mtime; + di->right.ctime = rent->ctime; + di->right.size = rent->size; + di->right.flags.attributes = rent->flags.attributes; } else { // Don't break CDirView::DoCopyLeftToRight() - di.right.filename = lent->filename; + di->right.filename = lent->filename; } - di.diffcode = code; + di->diffcode = code; GetLog()->Write ( CLogFile::LCOMPAREDATA, _T("name=<%s>, leftdir=<%s>, rightdir=<%s>, code=%d"), - di.left.filename.c_str(), di.left.path.c_str(), di.right.path.c_str(), code + di->left.filename.c_str(), di->left.path.c_str(), di->right.path.c_str(), code ); myStruct->context->m_pCompareStats->IncreaseTotalItems(); ReleaseSemaphore(myStruct->hSemaphore, 1, 0); - return &di; + return di; } void // static This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |