[David Abrahams] > That's exactly the sort of case that covers up bugs in C++. > > Our operator delete basically just ignores NULL values. When people > write > > delete p; p = 0; > > It can cover up bugs where p is unintentionally getting deleted > twice. It might still not be applicable here, though. Understood. Py_CLEAR isn't about deallocation, it's about a container releasing *a* reference it owns to a containee. The container doesn't know, and doesn't care, whether it's releasing the last reference to the containee. Once a container no longer refers to a containee, that's all the NULL means -- "I no longer refer to anything here", not necessarily "the thing I referenced is no longer referenced by anyone and has been recycled". The former containee *may* get recycled at this point, and it's important for the container to record that it no longer references it before any destructors associated with the containee get executed. This is harmless. But it's something people often do in a wrong order, which is why it's a Good Idea to have a macro capturing the right order. A wrong order can lead to horridly subtle bugs.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4