Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couple of Null check corrections #44

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

ya1gaurav
Copy link
Contributor

  1. m_to_python is checked against Null at line 70, but not checked at 89.
  2. !! is same as without using this.

1. m_to_python is checked against Null at line 70, but not checked at 89.
2. !! is same as without using this.
Applied patch to free node when node->next is Null but node is Non-Null.
if condition modified to use else.
@ya1gaurav
Copy link
Contributor Author

Please review updated patches. Thanks.

delete node;
delete node;
}
else if( node )

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are checking if node is not null two times instead of one. And the delete operator is a no-op when the pointer is null, this whole thing can be simply written as:

if (node != 0)
    delete_node(node->next);
delete node;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree delete NULL is safe.

delete handles NULL pointer, so there is no harm in removing extra NULL checks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants