#168: unique smart pointers for local variables

This commit is contained in:
Andrey Prygunkov
2016-02-14 17:04:13 +01:00
parent 36fe905bd9
commit c96d2259ce
12 changed files with 126 additions and 152 deletions

View File

@@ -376,9 +376,12 @@ bool QueueEditor::EditList(DownloadQueue* downloadQueue, IdList* idList, NameLis
m_downloadQueue = downloadQueue;
bool ok = true;
std::unique_ptr<IdList> nameIdList;
if (nameList)
{
idList = new IdList();
nameIdList = std::make_unique<IdList>();
idList = nameIdList.get();
ok = BuildIdListFromNameList(idList, nameList, matchMode, action);
}
@@ -386,11 +389,6 @@ bool QueueEditor::EditList(DownloadQueue* downloadQueue, IdList* idList, NameLis
m_downloadQueue->Save();
if (nameList)
{
delete idList;
}
return ok;
}
@@ -714,13 +712,12 @@ bool QueueEditor::BuildIdListFromNameList(IdList* idList, NameList* nameList, Do
for (CString& name : nameList)
{
RegEx *regEx = nullptr;
std::unique_ptr<RegEx> regEx;
if (matchMode == DownloadQueue::mmRegEx)
{
regEx = new RegEx(name);
regEx = std::make_unique<RegEx>(name);
if (!regEx->IsValid())
{
delete regEx;
return false;
}
}
@@ -759,8 +756,6 @@ bool QueueEditor::BuildIdListFromNameList(IdList* idList, NameList* nameList, Do
}
}
delete regEx;
if (!found && (matchMode == DownloadQueue::mmName))
{
return false;