Remove unnecessary null pointer checks. #188

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

@elfring
Contributor
elfring commented Jan 15, 2014

Explicit null pointer checks are performed at some source code places before pointers are passed to the C++ delete operator. This is unnecessary because the delete operator will care for such parameter validation already.

This is a follow-up to a previous update suggestion.

@elfring elfring Bug #169: Removed unnecessary null pointer checks
Explicit null pointer checks were performed at some source code places
before pointers were passed to the C++ delete operator. This was unnecessary
because the delete operator will care for such parameter validation already.
http://www.parashift.com/c++-faq/delete-handles-null.html

Redundant checks were removed.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
d13aa06
@roystgnr roystgnr commented on the diff Jan 15, 2014
src/base/libmesh_singleton.C
@@ -102,7 +102,6 @@ namespace libMesh
for (SingletonList::reverse_iterator it = singleton_cache.rbegin();
it!=singleton_cache.rend(); ++it)
{
- libmesh_assert (*it != NULL);
@roystgnr
roystgnr Jan 15, 2014 Member

This assertion isn't making sure the delete is safe, it's double-checking consistency of singleton_cache; I'd leave it in.

@roystgnr roystgnr commented on the diff Jan 15, 2014
src/geom/reference_elem.C
@@ -59,7 +59,6 @@ namespace
~SingletonCache()
{
for (unsigned int e=0; e<elem_list.size(); e++)
- if (elem_list[e])
{
@roystgnr
roystgnr Jan 15, 2014 Member

We might want to redo the indentation on these blocks since we're taking away one level of control structure?

@roystgnr
Member

I'd prefer if that one assertion remained and if those two blocks were reindented first, but I'd even be happy if this gets merged as-is. Thanks!

@jwpeterson
Member

Roy's suggestions have been implemented and this branch has been manually merged in a4ee2a4. Closing this PR.

@jwpeterson jwpeterson closed this Apr 15, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment