Skip to content

Remove unnecessary nullptr checks#3271

Open
astrelsky wants to merge 1 commit intoNationalSecurityAgency:masterfrom
astrelsky:NoNullCheck
Open

Remove unnecessary nullptr checks#3271
astrelsky wants to merge 1 commit intoNationalSecurityAgency:masterfrom
astrelsky:NoNullCheck

Conversation

@astrelsky
Copy link
Contributor

@astrelsky astrelsky commented Jul 28, 2021

if (types != (TypeFactory *)0)
delete types;
if (translate != (Translate *)0)
delete translate;
if (loader != (LoadImage *)0)
delete loader;
if (pcodeinjectlib != (PcodeInjectLibrary *)0)
delete pcodeinjectlib;
if (commentdb != (CommentDatabase *)0)
delete commentdb;
if (stringManager != (StringManager *)0)
delete stringManager;
if (cpool != (ConstantPool *)0)
delete cpool;
if (context != (ContextDatabase *)0)
delete context;

The C++ language GUARANTEES that delete will do nothing if given a nullptr.
https://isocpp.org/wiki/faq/freestore-mgmt#delete-handles-null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants