mirror of
https://github.com/nzbget/nzbget.git
synced 2026-04-30 17:42:36 -04:00
#168: unique smart pointers for local variables
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user