Remove the test of null pointer for delete

Since deleting a null pointer just does nothing:
https://isocpp.org/wiki/faq/freestore-mgmt#delete-handles-null
This commit is contained in:
Don HO 2019-04-06 16:43:23 +02:00
parent f55c4e3d26
commit 784eea3ef7
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
14 changed files with 20 additions and 44 deletions

View File

@ -1350,12 +1350,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
case NPPM_INTERNAL_FINDKEYCONFLICTS:
{
if (not wParam || not lParam) // Clean up current session
{
if (_pShortcutMapper != nullptr)
{
delete _pShortcutMapper;
_pShortcutMapper = nullptr;
}
return TRUE;
}

View File

@ -883,7 +883,6 @@ NppParameters::~NppParameters()
bool NppParameters::reloadStylers(TCHAR* stylePath)
{
if (_pXmlUserStylerDoc)
delete _pXmlUserStylerDoc;
const TCHAR* stylePathToLoad = stylePath != nullptr ? stylePath : _stylerPath.c_str();
@ -937,7 +936,6 @@ bool NppParameters::reloadLang()
return false;
}
if (_pXmlNativeLangDocA)
delete _pXmlNativeLangDocA;
_pXmlNativeLangDocA = new TiXmlDocumentA();

View File

@ -772,7 +772,6 @@ bool AutoCompletion::setLanguage(LangType language) {
wcscat_s(path, getApiFileName());
wcscat_s(path, TEXT(".xml"));
if (_pXmlFile)
delete _pXmlFile;
_pXmlFile = new TiXmlDocument(path);

View File

@ -62,7 +62,6 @@ public:
};
~AutoCompletion(){
if (_pXmlFile)
delete _pXmlFile;
};

View File

@ -233,7 +233,6 @@ const int STYLING_MASK = 255;
FindReplaceDlg::~FindReplaceDlg()
{
_tab.destroy();
if (_pFinder)
delete _pFinder;
for (int n = static_cast<int32_t>(_findersOfFinder.size()) - 1; n >= 0; n--)
{
@ -1658,8 +1657,6 @@ bool FindReplaceDlg::processFindNext(const TCHAR *txt2find, const FindOption *op
delete [] pText;
return true;
}

View File

@ -90,7 +90,6 @@ void FunctionCallTip::setLanguageXML(TiXmlElement * pXmlKeyword)
reset();
// Also clear _funcName so that next getCursorFunction will call loadFunction to parse XML structure
if (_funcName)
delete [] _funcName;
_funcName = 0;
}
@ -281,10 +280,8 @@ bool FunctionCallTip::getCursorFunction()
}
if (!same)
{ //check if we need to reload data
if (_funcName)
{
delete [] _funcName;
}
_funcName = new TCHAR[funcToken.length+1];
wcscpy_s(_funcName, funcToken.length+1, funcToken.token);
res = loadFunction();
@ -461,7 +458,6 @@ void FunctionCallTip::reset() {
void FunctionCallTip::cleanup() {
reset();
if (_funcName)
delete [] _funcName;
_funcName = 0;
_pEditView = NULL;

View File

@ -206,7 +206,6 @@ public:
{
for (StyleMap::iterator it2(it->second->begin()) ; it2 != it->second->end() ; ++it2)
{
if (it2->second._fontName != NULL)
delete [] it2->second._fontName;
}
delete it->second;

View File

@ -263,7 +263,6 @@ INT_PTR CALLBACK ClipboardHistoryPanel::run_dlgProc(UINT message, WPARAM wParam,
catch (...)
{
MessageBox(_hSelf, TEXT("Cannot process this clipboard data in the history:\nThe data is too large to be treated."), TEXT("Clipboard problem"), MB_OK | MB_APPLMODAL);
if (c)
delete[] c;
}
}

View File

@ -49,7 +49,6 @@ public:
explicit ByteArray(ClipboardData cd);
~ByteArray() {
if (_pBytes)
delete [] _pBytes;
_pBytes = NULL;
_length = 0;

View File

@ -39,7 +39,6 @@ FunctionParsersManager::~FunctionParsersManager()
delete _parsers[i];
}
if (_pXmlFuncListDoc)
delete _pXmlFuncListDoc;
}

View File

@ -69,13 +69,10 @@ FileDialog::FileDialog(HWND hwnd, HINSTANCE hInst)
}
FileDialog::~FileDialog()
{
if (_fileExt)
{
delete[] _fileExt;
_fileExt = NULL;
}
}
// This function set and concatenate the filter into the list box of FileDialog.
// The 1st parameter is the description of the file type, the 2nd .. Nth parameter(s) is (are)

View File

@ -47,7 +47,6 @@ enum
StatusBar::~StatusBar()
{
if (_lpParts != nullptr)
delete[] _lpParts;
}

View File

@ -502,7 +502,6 @@ void Accelerator::updateShortcuts()
size_t nbUserCmd = userCommands.size();
size_t nbPluginCmd = pluginCommands.size();
if (_pAccelArray)
delete [] _pAccelArray;
_pAccelArray = new ACCEL[nbMenu+nbMacro+nbUserCmd+nbPluginCmd];
vector<ACCEL> incrFindAcc;

View File

@ -360,7 +360,6 @@ public:
::DestroyAcceleratorTable(_hIncFindAccTab);
if (_hFindAccTab)
::DestroyAcceleratorTable(_hFindAccTab);
if (_pAccelArray)
delete [] _pAccelArray;
};
void init(HMENU hMenu, HWND menuParent) {