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:
parent
f55c4e3d26
commit
784eea3ef7
@ -1350,12 +1350,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||||||
case NPPM_INTERNAL_FINDKEYCONFLICTS:
|
case NPPM_INTERNAL_FINDKEYCONFLICTS:
|
||||||
{
|
{
|
||||||
if (not wParam || not lParam) // Clean up current session
|
if (not wParam || not lParam) // Clean up current session
|
||||||
{
|
|
||||||
if (_pShortcutMapper != nullptr)
|
|
||||||
{
|
{
|
||||||
delete _pShortcutMapper;
|
delete _pShortcutMapper;
|
||||||
_pShortcutMapper = nullptr;
|
_pShortcutMapper = nullptr;
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -883,7 +883,6 @@ NppParameters::~NppParameters()
|
|||||||
|
|
||||||
bool NppParameters::reloadStylers(TCHAR* stylePath)
|
bool NppParameters::reloadStylers(TCHAR* stylePath)
|
||||||
{
|
{
|
||||||
if (_pXmlUserStylerDoc)
|
|
||||||
delete _pXmlUserStylerDoc;
|
delete _pXmlUserStylerDoc;
|
||||||
|
|
||||||
const TCHAR* stylePathToLoad = stylePath != nullptr ? stylePath : _stylerPath.c_str();
|
const TCHAR* stylePathToLoad = stylePath != nullptr ? stylePath : _stylerPath.c_str();
|
||||||
@ -937,7 +936,6 @@ bool NppParameters::reloadLang()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_pXmlNativeLangDocA)
|
|
||||||
delete _pXmlNativeLangDocA;
|
delete _pXmlNativeLangDocA;
|
||||||
|
|
||||||
_pXmlNativeLangDocA = new TiXmlDocumentA();
|
_pXmlNativeLangDocA = new TiXmlDocumentA();
|
||||||
|
@ -772,7 +772,6 @@ bool AutoCompletion::setLanguage(LangType language) {
|
|||||||
wcscat_s(path, getApiFileName());
|
wcscat_s(path, getApiFileName());
|
||||||
wcscat_s(path, TEXT(".xml"));
|
wcscat_s(path, TEXT(".xml"));
|
||||||
|
|
||||||
if (_pXmlFile)
|
|
||||||
delete _pXmlFile;
|
delete _pXmlFile;
|
||||||
|
|
||||||
_pXmlFile = new TiXmlDocument(path);
|
_pXmlFile = new TiXmlDocument(path);
|
||||||
|
@ -62,7 +62,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
~AutoCompletion(){
|
~AutoCompletion(){
|
||||||
if (_pXmlFile)
|
|
||||||
delete _pXmlFile;
|
delete _pXmlFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -233,7 +233,6 @@ const int STYLING_MASK = 255;
|
|||||||
FindReplaceDlg::~FindReplaceDlg()
|
FindReplaceDlg::~FindReplaceDlg()
|
||||||
{
|
{
|
||||||
_tab.destroy();
|
_tab.destroy();
|
||||||
if (_pFinder)
|
|
||||||
delete _pFinder;
|
delete _pFinder;
|
||||||
for (int n = static_cast<int32_t>(_findersOfFinder.size()) - 1; n >= 0; n--)
|
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;
|
delete [] pText;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,6 @@ void FunctionCallTip::setLanguageXML(TiXmlElement * pXmlKeyword)
|
|||||||
reset();
|
reset();
|
||||||
|
|
||||||
// Also clear _funcName so that next getCursorFunction will call loadFunction to parse XML structure
|
// Also clear _funcName so that next getCursorFunction will call loadFunction to parse XML structure
|
||||||
if (_funcName)
|
|
||||||
delete [] _funcName;
|
delete [] _funcName;
|
||||||
_funcName = 0;
|
_funcName = 0;
|
||||||
}
|
}
|
||||||
@ -281,10 +280,8 @@ bool FunctionCallTip::getCursorFunction()
|
|||||||
}
|
}
|
||||||
if (!same)
|
if (!same)
|
||||||
{ //check if we need to reload data
|
{ //check if we need to reload data
|
||||||
if (_funcName)
|
|
||||||
{
|
|
||||||
delete [] _funcName;
|
delete [] _funcName;
|
||||||
}
|
|
||||||
_funcName = new TCHAR[funcToken.length+1];
|
_funcName = new TCHAR[funcToken.length+1];
|
||||||
wcscpy_s(_funcName, funcToken.length+1, funcToken.token);
|
wcscpy_s(_funcName, funcToken.length+1, funcToken.token);
|
||||||
res = loadFunction();
|
res = loadFunction();
|
||||||
@ -461,7 +458,6 @@ void FunctionCallTip::reset() {
|
|||||||
|
|
||||||
void FunctionCallTip::cleanup() {
|
void FunctionCallTip::cleanup() {
|
||||||
reset();
|
reset();
|
||||||
if (_funcName)
|
|
||||||
delete [] _funcName;
|
delete [] _funcName;
|
||||||
_funcName = 0;
|
_funcName = 0;
|
||||||
_pEditView = NULL;
|
_pEditView = NULL;
|
||||||
|
@ -206,7 +206,6 @@ public:
|
|||||||
{
|
{
|
||||||
for (StyleMap::iterator it2(it->second->begin()) ; it2 != it->second->end() ; ++it2)
|
for (StyleMap::iterator it2(it->second->begin()) ; it2 != it->second->end() ; ++it2)
|
||||||
{
|
{
|
||||||
if (it2->second._fontName != NULL)
|
|
||||||
delete [] it2->second._fontName;
|
delete [] it2->second._fontName;
|
||||||
}
|
}
|
||||||
delete it->second;
|
delete it->second;
|
||||||
|
@ -263,7 +263,6 @@ INT_PTR CALLBACK ClipboardHistoryPanel::run_dlgProc(UINT message, WPARAM wParam,
|
|||||||
catch (...)
|
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);
|
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;
|
delete[] c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,6 @@ public:
|
|||||||
explicit ByteArray(ClipboardData cd);
|
explicit ByteArray(ClipboardData cd);
|
||||||
|
|
||||||
~ByteArray() {
|
~ByteArray() {
|
||||||
if (_pBytes)
|
|
||||||
delete [] _pBytes;
|
delete [] _pBytes;
|
||||||
_pBytes = NULL;
|
_pBytes = NULL;
|
||||||
_length = 0;
|
_length = 0;
|
||||||
|
@ -39,7 +39,6 @@ FunctionParsersManager::~FunctionParsersManager()
|
|||||||
delete _parsers[i];
|
delete _parsers[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_pXmlFuncListDoc)
|
|
||||||
delete _pXmlFuncListDoc;
|
delete _pXmlFuncListDoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,13 +69,10 @@ FileDialog::FileDialog(HWND hwnd, HINSTANCE hInst)
|
|||||||
}
|
}
|
||||||
|
|
||||||
FileDialog::~FileDialog()
|
FileDialog::~FileDialog()
|
||||||
{
|
|
||||||
if (_fileExt)
|
|
||||||
{
|
{
|
||||||
delete[] _fileExt;
|
delete[] _fileExt;
|
||||||
_fileExt = NULL;
|
_fileExt = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// This function set and concatenate the filter into the list box of FileDialog.
|
// 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)
|
// The 1st parameter is the description of the file type, the 2nd .. Nth parameter(s) is (are)
|
||||||
|
@ -47,7 +47,6 @@ enum
|
|||||||
|
|
||||||
StatusBar::~StatusBar()
|
StatusBar::~StatusBar()
|
||||||
{
|
{
|
||||||
if (_lpParts != nullptr)
|
|
||||||
delete[] _lpParts;
|
delete[] _lpParts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -502,7 +502,6 @@ void Accelerator::updateShortcuts()
|
|||||||
size_t nbUserCmd = userCommands.size();
|
size_t nbUserCmd = userCommands.size();
|
||||||
size_t nbPluginCmd = pluginCommands.size();
|
size_t nbPluginCmd = pluginCommands.size();
|
||||||
|
|
||||||
if (_pAccelArray)
|
|
||||||
delete [] _pAccelArray;
|
delete [] _pAccelArray;
|
||||||
_pAccelArray = new ACCEL[nbMenu+nbMacro+nbUserCmd+nbPluginCmd];
|
_pAccelArray = new ACCEL[nbMenu+nbMacro+nbUserCmd+nbPluginCmd];
|
||||||
vector<ACCEL> incrFindAcc;
|
vector<ACCEL> incrFindAcc;
|
||||||
|
@ -360,7 +360,6 @@ public:
|
|||||||
::DestroyAcceleratorTable(_hIncFindAccTab);
|
::DestroyAcceleratorTable(_hIncFindAccTab);
|
||||||
if (_hFindAccTab)
|
if (_hFindAccTab)
|
||||||
::DestroyAcceleratorTable(_hFindAccTab);
|
::DestroyAcceleratorTable(_hFindAccTab);
|
||||||
if (_pAccelArray)
|
|
||||||
delete [] _pAccelArray;
|
delete [] _pAccelArray;
|
||||||
};
|
};
|
||||||
void init(HMENU hMenu, HWND menuParent) {
|
void init(HMENU hMenu, HWND menuParent) {
|
||||||
|
Loading…
Reference in New Issue
Block a user