Rationale:
delete ptris a no-op ifptrisnullptr
Rationale:
delete ptr is a no-op if ptr is nullptrIs that completely safe?
AFAIK the C++03 standard kept deleting a nullptr (NULL) as undefined. Not sure about C++11.
According to https://stackoverflow.com/questions/25329576/calling-delete-on-null-pointers-c03-vs-c11, C++11 (accidentally?) dropped the requirement that deleting a nullptr is a noop, and C++14 is clearer about it again.
Ouch, if I'm mistaken regarding delete NULL being a no-op in C++11. If that is the case I'll instead take a look at all delete:s in the code base to make sure that we are not accidentally doing any potential delete NULL:s.
Ouch, if I'm mistaken regarding delete NULL being a no-op in C++11
We assume universally that delete NULL is a no-op. 99% of actual C++ code out there does so. This is just a language lawyer's argument. No compiler will break that behavior. As it is resolved again for C++14, please don't plow over the entire source code to remove that assumption.
@laanwj Yes, that was my assumption from the beginning :-) This PR should be completely safe then and consistent with the assumptions made in the rest of the code base with regards to delete NULL being a no-op.
Rationale:
* delete ptr is a no-op if ptr is nullptr
Rebased!
2752 | @@ -2753,8 +2753,7 @@ CNode::~CNode() 2753 | { 2754 | CloseSocket(hSocket); 2755 | 2756 | - if (pfilter) 2757 | - delete pfilter; 2758 | + delete pfilter;
BTW as this one is a) in a destructor b) at the end of the destructor, why aren't we using a smart pointer w/ RAII?
post-merge-obvious utACK b109a1c3962a9f45fb5819afd69c7caaf78eb35e